2

I have some trouble using the RFID-RC522 reader with my RPi. It was working in the past, but now it stopped. I'm trying to find if a configuration changed somewhere and I also looked at the code of the MFRC522 library where is the problem.

I have a second Pi that is working and I could do some comparisons. First, I used the spidev_test.c program to check and I could see a difference between both Pi :
On the working Pi

mode is 0 after SPI_IOC_WR, return code is 0
mode is 0 after SPI_IOC_RD, return code is 0
spi mode: 0
bits per word: 8
max speed: 500000 Hz (500 KHz)

FF FF FF FF FF FF
40 00 00 00 00 95
FF FF FF FF FF FF
FF FF FF FF FF FF
FF FF FF FF FF FF
DE AD BE EF BA AD
F0 0D

On the broken one :

mode is 0 after SPI_IOC_WR, return code is 0
mode is 4 after SPI_IOC_RD, return code is 0
spi mode: 4
bits per word: 8
max speed: 500000 Hz (500 KHz)

FF FF FF FF FF FF
40 00 00 00 00 95
FF FF FF FF FF FF
FF FF FF FF FF FF
FF FF FF FF FF FF
DE AD BE EF BA AD
F0 0D

I connected the MOSI and MISO pins together (and added 2 prints in the original code). It looks like there is a difference in the SPI mode between both RPi. Could it be the problem? I don't really know the meaning of it and how to change it.

On the internet, I found that the SPI mode describes the polarity and the phase of the clock. But the values should be 0, 1, 2 or 3. Here I have 4, is there another SPI mode?

7
  • I almost always use SPI 0,0.
    – tlfong01
    Jul 14 at 11:14
  • spi mode: 4 is mode 0 with SPI_CS_HIGH 0x04 / chipselect active high? you say "It was working in the past, but now it stopped" - what has changed? When you say you have a working one and a broken one, does that mean the RC522 works on one pi and not the other? What mode pi's are they?
    – Bravo
    Jul 15 at 0:20
  • @Bravo I don't know what changed actually (probably after installing some stuff?). Yeah On one RPi everything works perfectly (and the spi mode = 0), but on the other one it doesn't work (and here, the spi mode = 4). I don't know why there is difference with the spi mode Jul 15 at 9:15
  • what model pis are each of them? the same? different?
    – Bravo
    Jul 15 at 9:17
  • The same, the RPi 4B Jul 15 at 9:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.