Skip to main content
Visitor II
March 2, 2021
Solved

SPI interface for STM32L476VG

  • March 2, 2021
  • 185 replies
  • 63548 views

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?

    This topic has been closed for replies.
    Best answer by Brian TIDAL

    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

    185 replies

    RShiv.1Author
    Visitor II
    March 10, 2021

    Hi BT,

    I have changed the SPI1_NSS to output psuh-pull, and also I have changed the correponding pin4 for PA4 and GPOIA.

    I have attached the changes .

    rgrds

    Ravi

    RShiv.1Author
    Visitor II
    March 10, 2021

    Hi BT,

    I am also attaching main.c where

    st25r3911WriteRegister( buf2, ST25R3911_TEST_REG_PATTERN );

    HAL_Delay(1000);

    st25r3911ReadTestRegister(buf2,val);

    is the syntax correct?...because we need to send a reg according to the function..just wanted to crosscheck on syntax.

    first wanted to read write the register...

    rgrds

    Ravi

    Technical Moderator
    March 10, 2021

    Hi,

    this is not in accordance with the st25r3911WriteRegister and therefore this is incorrect. .

    Rgds

    BT

    RShiv.1Author
    Visitor II
    March 10, 2021

    Hi BT,

    I had used st25r3911ReadTestRegister instead of st25r3911ReadRegister. also I have changed the mode

     st25r3911WriteRegister( ST25R3911_REG_MODE, ST25R3911_TEST_REG_PATTERN );

       HAL_Delay(1000);

      st25r3911ReadRegister(ST25R3911_REG_MODE,&val);

    Let me know if this is correct.

    rgrds

    Ravi

    RShiv.1Author
    Visitor II
    March 10, 2021

    Hi BT,

    Now I am getting output val in val reg as 0xFF

    Technical Moderator
    March 10, 2021

    Hi Ravi,

    any reason not to use what we have suggested in previous posts for testing register read/write i.e writing a test pattern in ST25R3911_REG_BIT_RATE and reading back the value?

    Anyway, obviously the SPI seems to be non operational.

    Can you check with your HW engineer the pin assignment between the MCU and the ST25R3911B? Can you describe in details your HW setup: is it a custom board with the MCU and the ST25R3911B or do you use a X-NUCLEO_NFC05A1 connected to the MCU through wire jumpers? Can you connect a logic analyzer on the SPI (SPI CLK, SPI MOSI, SPI MISO and SPI SS) and check the signals?

    Rgds

    BT

    RShiv.1Author
    Visitor II
    March 10, 2021

    HI BT,

    Now I tested with ST25R3911_REG_BIT_RATE  and SPI read register...then also I got 0xFF.

    yes this is a custom board with STM32L476VG(MCU) connected to ST25R3911B...The custom board is already there to use and all SPI connections are already done.

    will test the signals and let you know.

    regards

    Ravi

    Technical Moderator
    March 10, 2021

    Hi Ravi,

    Can you recheck the SPI configuration as it seems that CPHA=1Edge has been used instead of CPHA=2Edge. NSSP is also not having the proper value: it should be disabled. Also, as you system clock seems to be 4MHz (vs 48MHz in the demo), I believe the SPI prescaler can be set to 2 to reach 2Mbps.

    Rgds

    BT

    RShiv.1Author
    Visitor II
    March 10, 2021

    Hi BT,

    even I changed these values..still not seeing any values ..attaching main.c..let me know if there are any changes.

    regards

    Ravi

    Technical Moderator
    March 10, 2021

    Hi,

     hspi1.Init.NSS = SPI_NSS_HARD_OUTPUT; is incorrect. It should be  hspi1.Init.NSS = SPI_NSS_SOFT; Can you verify this parameter in your STM32CubeMX configuration?

    Rgds

    BT

    RShiv.1Author
    Visitor II
    March 10, 2021

    Hi BT,

    yes I even changed when I was doing other changes and did the test..still no SPI ouput values..

    Hope from S/W side we are all correct so that atleast hardware wise we can test.

    regards

    Ravi