I’m trying to use the MFRC522 library to read RFID Mifare cards. This library (https://github.com/miguelbalboa/rfid) was written for Arduino and although it was not specifically written for STM32 it seems to compile without errors for my STM32F103C8T6 ARM STM32 Minimum System Dev Board. Unfortunately I did not managed to make it work. There seems to be some SPI communication failure.
I was able to use this rfid reader (http://www.electrodragon.com/product/mifare-rc522-rfid-card-readerdetector-ic-card/) previously with a Pro Mini, so I’m confident it is not broken and I do understand how to make the wiring for both Pro Mini and STM32F103C8T6 boards, so the problem is definitely on the software side.
Does anyone have any positive experience making this particular RFID reader work with the MFRC522 lib on the STM32?
Thanks!
Adrian
If that is the case, try to use some other GPIO pin for CS.
Excellent advice. It works after changing the SS pin. The lib also seems to need some tweaking to move some pinMode calls out of the MFRC522 constructor into an init function that is called in setup().
I still have some minor issues but it generally works and I think I’ll start to port this one.
Thanks!
Excellent advice. It works after changing the SS pin. The lib also seems to need some tweaking to move some pinMode calls out of the MFRC522 constructor into an init function that is called in setup().
I still have some minor issues but it generally works and I think I’ll start to port this one.
Thanks!
Adrian
Thanks for letting us know
It compiles fine but the code seems to crash at
SPI.beginTransaction(SPISettings(SPI_CLOCK_DIV4, MSBFIRST, SPI_MODE0)); // Set the settings to work with SPI busI just added that line to my blink code and it still runs OK
#include "SPI.h"
int counter=0;
void setup() {
// put your setup code here, to run once:
pinMode(PB12,OUTPUT);
Serial.begin(250000);
SPI.beginTransaction(SPISettings(SPI_CLOCK_DIV4, MSBFIRST, SPI_MODE0));
}
bool v=false;
void loop() {
Serial.println(counter++);
// put your main code here, to run repeatedly:
digitalWrite(PB12,v);
delay(50);
v=!v;
}
LE: my mistake, I had the “mfrc522.PCD_DumpVersionToSerial(); ” commented out…
remember the data types are different in ARM than AVR e.g. int is 32 bit, double really is double, “word” may be a different size to what the AVR code thinks it is.
Look carefully at the data types you are reading from the peripheral, you may need to change the variable declarations to explicitly set the size e.g. uint16_t etc
Moved the
#define F(x) xCan we find an workaround, other than replacing all th F() in that library ?
Or I guess you could modify WString where the existing F macro is defined


