2023-04-25 12:20 AM
Hello there, STM32 community!
I am new to the STM32 family and I am currently working on a project to read and write Mifare Classic and Desfire tags. For this, I am using an STM32G071-NUCLEO64 microcontroller and a X-NUCLEO-NFC05A1 (ST25R3911B) board connected via SPI. I have been trying to establish the SPI connection between the two devices and send/receive data, but so far, I have not been successful.
Initially, I tried to use the SPI example provided in STM32CubeIDE, but I was not able to receive data correctly.
Then, I followed a post on the ST community website to use the RFAL/NDEF libraries for my project. However, the post was for the 32f070RB board, and I had to make some modifications to make it work with my hardware.
Unfortunately, after copying the RFAL and NDEF libraries into my project, modifying the platform.h file, and adding the necessary modules, I am still unable to get it working.
The error I am receiving is:
#define ERR_HW_MISMATCH ((ReturnCode)36U) /*!< expected hw do not match */
after executing rfalNfcInitialize().
I am feeling lost and unable to find a suitable example for my specific case.
Can someone please guide me on how to initialize the connection between the STM32G071 and the ST25R3911B chip?
What is the best way to receive data and work with it?
Thank you very much for your time and help!
Solved! Go to Solution.
2023-04-26 02:54 AM
Nope! In platform.h the only thing I change is the EXTI0_IRQn for EXTI0_1_IRQn because STM32G0 doesn't accept EXTI0_IRQn.
And in main.h I just add these defines:
/* GPIO PORT: A */
#define IRQ_3911_Pin GPIO_PIN_0
#define IRQ_3911_GPIO_Port GPIOA
#define IRQ_3911_EXTI_IRQn EXTI0_IRQn
#define LED_F_Pin GPIO_PIN_1
#define LED_F_GPIO_Port GPIOA
#define LED_B_Pin GPIO_PIN_4
#define LED_B_GPIO_Port GPIOA
#define LED_FIELD_Pin GPIO_PIN_8
#define LED_FIELD_GPIO_Port GPIOA
#define TMS_Pin GPIO_PIN_13
#define TMS_GPIO_Port GPIOA
#define TCK_Pin GPIO_PIN_14
#define TCK_GPIO_Port GPIOA
/* GPIO PORT: B */
#define LED_A_Pin GPIO_PIN_0
#define LED_A_GPIO_Port GPIOB
#define SWO_Pin GPIO_PIN_3
#define SWO_GPIO_Port GPIOB
#define LED_V_Pin GPIO_PIN_4
#define LED_V_GPIO_Port GPIOB
#define LED_AP2P_Pin GPIO_PIN_5
#define LED_AP2P_GPIO_Port GPIOB
#define SPI1_CS_Pin GPIO_PIN_6
#define SPI1_CS_GPIO_Port GPIOB
/* GPIO PORT: C */
#define B1_Pin GPIO_PIN_13
#define B1_GPIO_Port GPIOC
that are called in the platform.h file and in the MX_GPIO_Init() function :downcast_face_with_sweat:
2023-04-26 04:58 AM - edited 2023-11-20 07:15 AM
yesterday set SPI pin to others:
today as B6. I'am confused
2023-04-26 05:39 AM
:face_screaming_in_fear: I'm sorry! I restarted the project from scratch because I was doing some tests and I must forgot to change the values in the #defines. Here's the updated with all the SPI ports updated!
/* GPIO PORT: A */
#define LED_F_Pin GPIO_PIN_1
#define LED_F_GPIO_Port GPIOA
#define LED_B_Pin GPIO_PIN_4
#define LED_B_GPIO_Port GPIOA
#define TCK_Pin GPIO_PIN_5
#define TCK_GPIO_Port GPIOA
#define LED_FIELD_Pin GPIO_PIN_8
#define LED_FIELD_GPIO_Port GPIOA
#define TMS_Pin GPIO_PIN_13
#define TMS_GPIO_Port GPIOA
/* GPIO PORT: B */
#define SPI1_CS_Pin GPIO_PIN_0
#define SPI1_CS_GPIO_Port GPIOB
#define LED_A_Pin GPIO_PIN_0
#define LED_A_GPIO_Port GPIOB
#define SWO_Pin GPIO_PIN_3
#define SWO_GPIO_Port GPIOB
#define IRQ_3911_Pin GPIO_PIN_4
#define IRQ_3911_GPIO_Port GPIOB
#define IRQ_3911_EXTI_IRQn EXTI0_1_IRQn
#define LED_V_Pin GPIO_PIN_4
#define LED_V_GPIO_Port GPIOB
#define LED_AP2P_Pin GPIO_PIN_5
#define LED_AP2P_GPIO_Port GPIOB
/* GPIO PORT: C */
#define B1_Pin GPIO_PIN_13
#define B1_GPIO_Port GPIOC
There are some #defines repeated (LEDS) because I don't know what PORT-PINS use and I let them as it came with the project...
I'm sorry again!!!
2023-04-26 06:53 AM
I presume helpful for such porting could also be the recipe provided by a customer in this thread:
https://community.st.com/s/question/0D53W00001Px5sKSAR/how-to-create-a-project-with-x-cube-nfc06
There may be some minor changes happened in the meantime but the general procedures should be useful.
Regards, Ulysses
2023-04-27 12:01 AM
Hello! I have already followed the instructions given, but unfortunately, I have not been successful in resolving the issue.
However, I have made progress by modifying the configuration files. Initially, I was confused about the port-pins that needed to be used, but now I have a good understanding of the correct configuration.
I am happy to report that I have made some progress, as all 6 LEDs on the X-NUCLEO-NFC05A1 board are now responding.
Please find the updated #defines below:
/* GPIO PORT: A */
#define IRQ_3911_Pin GPIO_PIN_0
#define IRQ_3911_GPIO_Port GPIOA
#define IRQ_3911_EXTI_IRQn EXTI0_1_IRQn
#define LED_F_Pin GPIO_PIN_1
#define LED_F_GPIO_Port GPIOA
#define LED_B_Pin GPIO_PIN_4
#define LED_B_GPIO_Port GPIOA
#define TCK_Pin GPIO_PIN_5
#define TCK_GPIO_Port GPIOA
#define LED_FIELD_Pin GPIO_PIN_8
#define LED_FIELD_GPIO_Port GPIOA
#define TMS_Pin GPIO_PIN_13
#define TMS_GPIO_Port GPIOA
/* GPIO PORT: B */
#define LED_A_Pin GPIO_PIN_1 // Schematic says PB0 but it doesn't work
#define LED_A_GPIO_Port GPIOB
#define SWO_Pin GPIO_PIN_3
#define SWO_GPIO_Port GPIOB
#define LED_V_Pin GPIO_PIN_4
#define LED_V_GPIO_Port GPIOB
#define LED_AP2P_Pin GPIO_PIN_5
#define LED_AP2P_GPIO_Port GPIOB
#define SPI1_CS_Pin GPIO_PIN_6
#define SPI1_CS_GPIO_Port GPIOB
/* GPIO PORT: C */
#define B1_Pin GPIO_PIN_13
#define B1_GPIO_Port GPIOC
However, I'm still facing an issue with the code returning the error "Hardware missmatch" when attempting to initialize RFAL.
PD: in the schematic of the NFC05A1 board the port-pin for the LED_A was PB0 but it didn't work, it actually is PB1!! (at least that's the one working for me)
Just for you information 🙂
2023-04-27 12:16 AM
I don't see PB1 on schematic. Please link me your manual.
2023-04-27 12:23 AM
There it is:
NFC card reader expansion board based on ST25R3911B for STM32 and STM8 Nucleos
Page 3/11, LED 103.
I'm just saying the problem with the LED is that in the schematic it says is the PB0 but I had to use it as PB1 to get it working.
But the main problem still is the Hardware missmatch... :sleepy_face:
2023-04-27 12:30 AM - edited 2023-11-20 07:15 AM
And what's your board?
2023-04-27 12:31 AM
STM32G071 , ok , I forgot :p
2023-04-27 12:37 AM
Exactly!:squinting_face_with_tongue:
I'm using the STM32F401RE-Nucleo example because is the most similar to my board...