Smartmatrix + teensy + rc522 rfid

Hello
I use my teensy + smartmatrix for displaying gifs in a musical project, along with a score

I would like to add a funny feature by introducing a rfid reader (rc522). It uses SPI but the rfid reader integration seems to add some strange colours on the display.

Do I need to use specific pins for this ? Is smartmatrix also sharing SPI pins ? ( rfid is using mosi miso sck sda pins from teensy 4.1)

Thanks a lot for your help

The SPI pins (11-13) are used by the Smartmatrix 4.x shield. On the Teensy 4.1 you can use the second SPI bus (pins 0, 1, 23). However, your RFID driver has to have an option to use the 2nd SPI bus instead of the first.

I believe that the Smartmatrix board uses pins 2, 3, 6 and 8-13 for the matrix display and pins 4, 5, and 22 for the APA102/dotstar LED string.

Hi Michael!
Thanks a lot for the help ! I found this example using rc522 on SPI1… I will try it soon, I’m pretty confident it should work :wink:


Will keep you posted !
Sebastien

From what I’ve seen on teensy 4.1
Miso1 pin 1
Mosi1 pin 26
Sck1 pin 27
Cs1 pin 0

MFRC522 is working perfectly with the pinout above,
I just had to use this lib instead of the Arduino MFRC522 : GitHub - miguelbalboa/rfid: Arduino RFID Library for MFRC522
The only change in software is as follow :

MFRC522 rfid(SS_PIN, RST_PIN, &SPI1);
SPI1.begin();

Thanks a lot Michael :slight_smile:

I’m glad it helped.

For most drivers, the CS1 pin can be any digital pin.

In the Teensy 3.x series, there were several special CS pins that some display drivers could use to optimize the display output if the CS and DC pins were in those special pins. As far as I know, these optimizations aren’t in the Teensy 4.1/4.0. If anybody does re-do this optimization, the special pins for SPI1 on the Teensy 4.1 are 0 and 38. On the Teensy 4.0, only pin 0 is a special pin (which means the optimization can’t be done, since it needs 2 pins).

On the Teensy 4.0, MISO1 has to be pin 0. On the Teensy 4.1, MISO1 can be either 0 or 33. If you use pin 33, you have to use:

  • SPI1.setMOSI(pin)

Doing this can be helpful if you need Serial1 (pins 0/1).

Hey,
MFRC522 is working fine with these pins, when I don’t use any other device, which looks to be regular pins for SPI1 :
Miso1 pin 1
Mosi1 pin 26
Sck1 pin 27
Cs1 pin 0


But MFRC522 is not working anymore when I add the smartmatrix code and the SD card. I understand from the picture that my SD card is using SPI2. Smart Matrix seems to be using SPI0, so I’m convinced it should work altogether with MFRC522 on SPI1…

On the Teensy 4.1, MISO1 can be either 0 or 33.

Are you sure ? From the drawing, MISO1 seems to be either 1 or 39.
CS1 can be 0 or 38, even if I understand it can be any digital pin.
MOSI1 seems to be 26 only, SCK1 seems to be 27 only.

I will try to move CS1 from 0 to 38, and MISO1 from 1 to 39, and will update you,
Thanks again Michael

Will also try to add these lines as suggested by you and also here : Teensy 4.1 and SPI1 ?
SPI1.setCS(38);
SPI1.setMISO(39);
SPI1.setMOSI(26);
SPI1.setSCK(27);

All is working fine, with the pins above :slight_smile:
the cable length is certainly the reason why the RFID device was not working.