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,

I don't think this is the issue.

I guess this shows the declaration of the function and therefore open the .h file.

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,

Then why we are seeing platformLog("Initialization failed..\r\n"); message in UART ....demoINI should have passed ...we are seeing this.

regards

Ravi

Brian TIDAL
ST Employee

Hi Ravi,

demoIni() runs the rfalInitialize() that runs the st25r3911CheckChipID() that needs a functional SPI to communicate with the ST25R3911B and retrieve the chipID. As the SPI is not functional, the chipID register is not properly returned and st25r3911CheckChipID() returns false and thus rfalInitiliaze() returns ERR_HW_MISMATCH. You just need to put a breakpoint in rfalInitiliaze and see that it will return an error.

Therefore demoIni is likely to fail as long as the SPI is not functional. By the way, this is why I have suggested in one of the previous posts to have the SPI read write test before the demoIni() rather than inside the while (1) loop.

I suggest you connect a logic analyzer on the SPI (MISO, MOSI, SS and CLK) and debug this issue with your HW engineer.

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,

Ok fine then S/W configuration wise we are through I guess ...I will let you know once I sit with H/W engg and let you know if there are anything required.

Thanks

Ravi

RShiv.1
Senior

Hi BT,

Does this more or less conclude this is H/W issue right??...S/W configuration wise we are fine I guess..let me know

regards

Ravi

RShiv.1
Senior

Hi BT,

As per your suggestion we were successfully able to get the SPI working since there was some issue in H/W related component.

After running the DemoINI we are getting successfull message and after writing the SPIwriteregister we are seeing SPI communication OK message.

1 .Now we are trying to write into SPI register and read the same using st25r3911ReadRegister , kindly let us know as we are not getting what we are writing into register.

2.As we are using St25R3911 wanted to know how we can configure GPIO input PA3 for the interrupt so that when we scan the RFID we wanted to read from the register.

3.we tried using demo cycle but this is used for ST_discovery we need to modify to work for our environment.chip used here is STM32L476RgTx.

Kindly let us know.

Thanks and regards

Ravi

Brian TIDAL
ST Employee

Hi Ravi,

Congratulations. Receiving "SPI Communication OK...." message means your STM32L476VG properly communicates with the ST25R3911B though SPI.

Regarding your question 1, can you elaborate on the issue you have: which register and which value? In my humble opinion, now that the SPI communication is properly working, I would integrate demo_cycle and the interrupt handling, get rid of the read/write register test code and would not spend time on low level register.

For your question 2, if I understand well, PA3 is connected to ST25R3911B IRQ pin. The configuration of the PA3 pin should follow the one called IRQ_3911B in the X-NUCLEO-NFC05A1.ioc I've sent you previously, basically external interrupt with falling edge trigger detection. Note in this configuration, ST25R3911B IRQ pin is connected to PA0 whereas this is PA3 on you side. So EXTI line 3 will be used on your side instead of EXTI line 0. Make sure to follow the recommandation I've already gave you previously for the proper configuration of the interrupt (search for EXTI on this page).

For your point 3, demo_cycle should work without any issue on your STM32L476VG as there is no dependency on MCU in this code. Just make sure to have the ST25R3911B interrupt being properly configured and to have the st25r3911Isr() being called in the EXTI3_IRQHandler handler as explained in point 2.

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 reply .

1.we are using STM32L476RG(lesser pin) with ST25R3911B through SPI.In the main.c I have posted the read/write register as I was trying to do SPI read/write to get known data flow.This is mainly to check read/write register is correct or not.

2.As you have suggested I will follow the interrput configuaration to get the ouput.once RFID is read the Interrupt is trigerred through which the value will come and sit in some register from where I have to read and check it in UART.which is the register and can we use read/write register for this?.Kindly let me know.

3.Once demo_cycle was included I am getting following message "platformLog("Toggling Wake Up mode %s\r\n", discParam.wakeupEnabled ? "ON": "OFF");" and it is not moving further.Do we require demo_cycle to check the RFID read and also to read from SPI register?.

Thanks and regards

Ravi

Brian TIDAL
ST Employee

Hi Ravi,

for point #3, the demo enters wake up mode when the NUCLEO-L476RG user button is pressed (i.e. when GPIO connected to the user button is low). This requires proper configuration of this GPIO connected to the user button. For the moment, I would suggest to undefine PLATFORM_USER_BUTTON_PORT and PLATFORM_USER_BUTTON_PIN.

For point #2: the ST25R3911B is an RFID frontend. Its role is to modulate the requests sent by the MCU and to demodulate the responses sent by the tag. Those requests and responses follow a certain protocol and this protocol is implemented on MCU side. Running the demo_cycle, will run the various protocol layers and will provide you the upper layer user data. As soon as the PA3 interrupt handling will be properly implemented, the demo_cycle willbe able to detect tags and to display their UID.

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 done the following changes as per your suggestions

1.changes made in PA3 to be configured as GPIO_EXTI3 , then also changed under GPIO settings user label to IRQ_3911 ,then later NVIC settings to EXTI line3 interrupt .

generated the code for this also.but I did not see any ISR code in main.c of X-CUBE-NFC5 project , where in main.c I need to add the code.I have attached my main.c for reference.

2.we have connected the RFID sensor to str3911 now ,so when card is shown should be able to see in hardware that interrupt is triggered, if so how do we check this in scope?Kindly let us know

Thanks and regards

Ravi