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?

1 ACCEPTED SOLUTION

Accepted Solutions
Brian TIDAL
ST Employee

Hi,

X-CUBE-NFC5 package provides an NFC polling demo using the RFAL and running on NUCLEO-L476RG (MCU board) + X-NUCLEO-NFC05A1 (ST25R3911B expansion board). It can be a good starting point for a project based on SYM32L476VG.

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.

View solution in original post

190 REPLIES 190
Brian TIDAL
ST Employee

Hi,

X-CUBE-NFC5 package provides an NFC polling demo using the RFAL and running on NUCLEO-L476RG (MCU board) + X-NUCLEO-NFC05A1 (ST25R3911B expansion board). It can be a good starting point for a project based on SYM32L476VG.

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 valuable inputs.I had a look into the package and also was able to compile it in ac6.

But we do not have a nucleo board to flash the same.we are currently using a custom board where we are integrating.

I would like to know if we can use the NFC package and folders such as middleware,directly copy and import into our project and compile??.also if I need to test the SPI interface how I can read the register in the ST25R3911B so that I know interfaces are fine.

kindly suggest how can we proceed from here it will very helpful.

regards

Ravi

Brian TIDAL
ST Employee

Hi Ravi,

yes you can import the various rfal and middleware files into your project. Make sure to

  • add the proper defines (USE_HAL_DRIVER,STM32L476xx,USE_LOGGER,ST25R3911) in your configuration.
  • define the various GPIOs according to your board (IRQ_3911 pin, SPI SS pin, LED pins - for the LED pin you can define fake pin if not used on your custom board). See definition in main.h
  • copy the code in /* USER CODE BEGIN 2 */ and  /* USER CODE BEGIN WHILE */ in your main()
  • change spiInit(&hspi1) if needed (e.g. if spi2 is used instead of spi1)

For testing the SPI, you can for example add the following code in st25r3911Initialize() in line 133

#define ST25R3911_TEST_REG_PATTERN       0x33U

  st25r3911WriteRegister( ST25R3911_REG_BIT_RATE, ST25R3911_TEST_REG_PATTERN );

  if( !st25r3911CheckReg( ST25R3911_REG_BIT_RATE, (ST25R3911_REG_BIT_RATE_mask_rxrate | ST25R3911_REG_BIT_RATE_mask_txrate), ST25R3911_TEST_REG_PATTERN ) )

{

/* error handling here */

return;

}

  /* Restore default value */

  st25r3911WriteRegister( ST25R3911_REG_BIT_RATE, 0x00 );

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.I was also trying to get the RFAL and middleware from STM32cubeMX.is this possible?

since I am newbee I was using older version 5.0.1 ,now I have installed recent version 6.1.2.

Here there are NFC bundle which can I select so that RFAL and middleware shall be generated..is this also possible? If so can you guide me.

Kindly throw some light on this.

regards

Ravi

Brian TIDAL
ST Employee

Hi Ravi,

if I am not wrong, NFC packages in STM32CubeMX are for NFC Dynamic Tags.

The RFAL and middleware are available in X-CUBE-NFC5 (with support of SW4STM32 ac6) or in the ST25 Embedded NFC library (more examples provided and latest RFAL, with STM32CubeIDE as default IDE). As your IDE seems to be SW4STM32, I've suggested to use X-CUBE-NFC5 package even if not having the latest RFAL.

I would suggest that you define your pinout and configuration and clocking thanks to STM32CubeMX, and generate the "skeleton" of you project then import the RFAL files into your project and follow the steps described in How to start with ST25R3911B and is It really necessary to use rfal and st25r3911 libraries for simpel 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,

Thanks for you valuable inputs.I was able to add the drivers ,middleware into my project and was successfully able to compile.

1 There were few erros which I could solve by adding required .h files and alos pointing to specific path.

2 I have not used demo.c and demo.h in my project ,actually is it necessary?? Kindly let me know.

My defines are like this

#define SPI1_CS_Pin GPIO_PIN_6

#define SPI1_CS_GPIO_Port GPIOA

#define IRQ_3911_Pin GPIO_PIN_0

#define IRQ_3911_GPIO_Port GPIOA

My Interrupt pin PA3

chip select is PA4

we are using SPI1 .Until this configuration is correct we cannot read or write.Kindly let us know.

regards

Ravi

RShiv.1
Senior

Hi BT,

attached us my main.c from where I am trying to do SPIwriteregister().kindly Let me know if it is correct.

we need to read write SPI so that we might use further in our application .

thanks

Ravi

RShiv.1
Senior

Hi BT,

I am getting following error when I try using St25Rwriteregister

C:\Users\RAVI\Documents\STM\UART_STM32_test\Debug/../Drivers/BSP/Components/ST25R3911/st25r3911_com.c:238: undefined reference to `globalCommProtectCnt'

this is define in platform.h ,then why I am getting the error..should I define this in any of the files.

Kindly let me know.

regards

Ravi

RShiv.1
Senior

Hi BT,

sorry to add too many questions...since we are using IRQ ..once IRQ is send from ST25R3911 to STM32L476VG I need to read the SPI register.

this will help us to read values.Kindly guide us.

regards

Ravi