cancel
Showing results for 
Search instead for 
Did you mean: 

SPI interface for STM32L476VG

RShiv.1
Senior

STM32L476VG is the MCU we are interfacing with ST25R3911B using SPI.

what we have understood from some search is that we need RFAL (abstraction layer) to interface with RF HAL.

Then once we integrate RFAL and RF HAL in our system workbench(ac6) project we need to build the integration then use SPI calls to read the register from RFID reader ST25R3911B

we wanted to use ISO-14443A standard to be configured and read the values.

where do we get the basic RFAL work space or code flow so that we shall use in our current project?

Kindly guide us and let us know are we in right path?

190 REPLIES 190
Brian TIDAL
ST Employee

Hi Ravi,

uint8_t globalCommProtectCnt = 0U; has to be defined in your main.c (see the reference main.c used in the polling demo).

I had a look to your main(). Please make sure to read back the ST25R3911_REG_BIT_RATE register value to verify the value has been properly written. Also, as explained in my previous posts, make sure to add the various initializations that are in /* USER CODE BEGIN 2 */ in particular  spiInit(&hspi1);. Without those initializations, the SPI communication and the logging in the RFAL will fail.

demo.c and demo.h are needed. Once the SPI will be working, make sure to remove your register write test code and to add the demoCycle() in the main loop.

Rgds

BT

In order to give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.
RShiv.1
Senior

Hi BT,

I added uint8_t globalCommProtectCnt = 0U; in main.c and the compiling went well.I will make sure to read back register..and also on initialization.

But why do we require demo.c and demo.h in our custom environment because we do not want to do ant platformledoff, and platformGpioIsLow..

If I add demo.c and demo.h I see lot of places where certain define are not defined..we are seeing these errors

#define PLATFORM_LED_A_PIN      LED_A_Pin       /*!< GPIO pin used for LED A  */

#define PLATFORM_LED_A_PORT     LED_A_GPIO_Port    /*!< GPIO port used for LED A  */

#define PLATFORM_LED_B_PIN      LED_B_Pin       /*!< GPIO pin used for LED B  */

#define PLATFORM_LED_B_PORT     LED_B_GPIO_Port    /*!< GPIO port used for LED B  */

#define PLATFORM_LED_F_PIN      LED_F_Pin       /*!< GPIO pin used for LED F  */

#define PLATFORM_LED_F_PORT     LED_F_GPIO_Port    /*!< GPIO port used for LED F  */

#define PLATFORM_LED_V_PIN      LED_V_Pin       /*!< GPIO pin used for LED V  */

#define PLATFORM_LED_V_PORT     LED_V_GPIO_Port    /*!< GPIO port used for LED V  */

#define PLATFORM_LED_AP2P_PIN    LED_AP2P_Pin     /*!< GPIO pin used for LED AP2P */

#define PLATFORM_LED_AP2P_PORT    LED_AP2P_GPIO_Port  /*!< GPIO port used for LED AP2P*/

LED_A_PIN not declared..likewise...

so is demo.c really required??

Kindly let us know

regards

Ravi

Brian TIDAL
ST Employee

Hi Ravi

as explained in previous post,  for the LED pin you can define fake pin if not used on your custom board (i.e. just assign to an unused GPIO).

demo.c provides the basic steps to communicate with a tag in respect with NFC protocol. This is usually used as a basis for customer applications i.e. this is used as a skeleton where one adds its specific application.

Feel free to share more information about your application that we can support you accordingly.

Rgds

BT

In order to give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.
RShiv.1
Senior

Hi BT,

Thanks for your response.Our current application need is ST25R3911 which would be connected to antenna where we want to read RFID cards and ST25R will generate interuppt to STM32L476VG so that we shall read the value through SPI.I was able to compile with demo.c along with the project.

I have also attached main.c where I have made changes in SPI..now can I do a dummy SPI write and SPI read to check whether SPI is working fine.kindly Let me know

regards

Ravi

Brian TIDAL
ST Employee

Hi Ravi,

yes you can do a dummy SPI read write to check the SPI communication with the ST25R3911.

For the next step, make sure to

  • align IRQ_3911_Pin  and IRQ_3911_GPIO to your actual interrupt pin (that seems to be PA3)
  • have st25r3911Isr(); being called in the EXTIxxxxx_IRQHandler interrupt call back
  • check that platformProtectST25RComm and platformUnprotectST25RComm properly disable/enable the right interrupt (it should be using IRQ_3911_EXTI_IRQn macro generated by STM32CubeMX)

Then I recommend again to call demoIni as part of /* USER CODE BEGIN 2 */ and to add demoCycle in the while (1) loop (/* USER CODE BEGIN WHILE */) to run the various steps of the NFC protocol.

Rgds

BT

In order to give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.
RShiv.1
Senior

HI BT,

I have include demoIni() and democycle as part of main.c but I am getting following errors

undefined reference to `rfalNfcGetDevicesFound

undefined reference to `rfalNfcSelect' ..I have include demo.c and in that rfal_nfc.h as #include "..\..\Middlewares\ST\rfal\Inc\rfal_nfc.h" as this is the structure of my project...still did not understand why I got this error.

also once this is integrated can I use  st25r3911WriteRegister( ST25R3911_REG_BIT_RATE, ST25R3911_TEST_REG_PATTERN ); so that I can do dummy SPI read and write

is this correct? ..or any other code snippet...this is withour IRQ interrupt pin.Kindly suggest us.

regards

Ravi

Brian TIDAL
ST Employee

Hi Ravi

I would suggest that you copy into your project the include paths from the reference project.

Then, also make sure to add the following include in your main.c:

/* USER CODE BEGIN Includes */
#include "demo.h"
#include "platform.h"
#include "spi.h"
#include "usart.h"
#include "logger.h"
#include "st_errno.h"
#include "rfal_nfc.h"
/* USER CODE END Includes */

Rgds

BT

In order to give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.
RShiv.1
Senior

Hi BT,

Its the demo.c that is throwing the problem

C:\Users\RAVI\Documents\STM\UART_STM32_test\Debug/../Core/Src/demo.c:160: undefined reference to `rfalNfcGetDevicesFound'

not the main.c ..even though the call is from main.c.I have attached demo.c code.

regards

Ravi

Brian TIDAL
ST Employee

Hi,

as explained in my previous post, I suggest that you update the include paths of your project from the demo project.

Rgds

BT

In order to give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.
RShiv.1
Senior

Hi BT,

I have compiled main.c with demoini and also democycle now..can you now let me know how I can test SPI read or write without IRQ pin just to test the code

It would be helpful if you give me snippet code if you have...kindly let me know.

regards

Ravi chandran