Page 1 of 1

PN532 on SPI not working

Posted: Thu May 02, 2024 9:24 am
by geologic
Hi all

I have a RFID PN532 module with SPI and i tested it with arduino using Adafruit_PN532 library, it works ok. I'm using these pins:

Code: Select all

#define PN532_SCK  13                                                   
#define PN532_MOSI 11                                                   
#define PN532_SS 16                                                     
#define PN532_MISO 12                                                   
Adafruit_PN532 nfc(PN532_SCK, PN532_MISO, PN532_MOSI, PN532_SS);
Next i test it with Nucleo 64 with these pins:

Code: Select all

#define PN532_SCK PA5                                                   
#define PN532_MOSI PA7                                                   
#define PN532_SS PA4                                                     
#define PN532_MISO PA6                                                   
Adafruit_PN532 nfc(PN532_SCK, PN532_MISO, PN532_MOSI, PN532_SS);
but the module is not recognized. I'm using the iso14443a_uid.pde example and it fails on this point:

Code: Select all

  nfc.begin();
  uint32_t versiondata = nfc.getFirmwareVersion();
  if (! versiondata) {
    Serial.print("Didn't find PN53x board");
    while (1); // halt
  }
I double checked the connections and tried a second module with the same behavior, a working SPI module in arduino is not recognized on STM32.

Any idea?

Re: PN532 on SPI not working

Posted: Tue May 07, 2024 7:27 am
by fpiSTM
Hi @geologic
Looking at the library, it seems you used Software SPI.
https://github.com/adafruit/Adafruit-PN ... #L143-L145

Which relies on https://github.com/adafruit/Adafruit_Bu ... PIDevice.h
So i guess there is an issue with this, maybe linked to this:
https://github.com/adafruit/Adafruit-GF ... y/pull/359

You can try to use Hardware SPI instead. As it seems you don't mention the board you used I can't check the value of pins you used.
See this to defined properly your SPI instance with the desired pins.