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
    April 9, 2021

    Hi BT,

    Thanks for the reply.Now once we check in the scope you need to get HIGH signal in the ST25R3911 pin,after this all the S/W configuarations are done..so I need to get the following print "platformLog("ISO14443A/Topaz (NFC-A ***) TAG found. UID: %s\r\n", hex2Str( nfcDevice->nfcid, nfcDevice->nfcidLen ) );..is this correct.

    can I read the RFID value from this structure nfcDevice->nfcid???

    regards

    Ravi

    Technical Moderator
    April 9, 2021

    Hi,

    as explained in the ST25R3911B datasheet, "When an interrupt condition is met, the source of interrupt bit is set in the Main interrupt register and the IRQ pin transitions to high", therefore make sure to have the following configuration for the GPIO connected to the ST25R3911B IRQ:

    0693W000008z715QAA.jpgThen, make sure to have the demoIni() being called only once in /* USER CODE BEGIN 2 */--/* USER CODE END 2 */ section (i.e. it shall ***not*** be in the while (1) loop). and then run the demoCycle() in the  /* USER CODE BEGIN WHILE */ --  /* USER CODE END WHILE */ section. See the reference main.c file.

    Once a tag is discovered, its UID is stored in nfcDevice->nfcid and the UID Length is stored in nfcDevice->nfcidLen.

    Rgds

    BT

    RShiv.1Author
    Visitor II
    April 9, 2021

    Hi BT,

    1.Yes our configurations matches with what you have told..demoini is called only once outside while and inside while we are using democycle.

    2.But we are seeing interrupt being generated once even without presenting our RFID ,after that when we present RFID we are seeing the INT

    .Is there any changes that need to made to these confiurations

    #define ST25R3911_REG_IO_CONF1_lf_clk_off           (1U<<0)

    #define ST25R3911_REG_IO_CONF1_out_cl0            (1U<<1)

    #define ST25R3911_REG_IO_CONF1_out_cl1            (1U<<2)

    #define ST25R3911_REG_IO_CONF1_mask_out_cl          (3U<<1)

    #define ST25R3911_REG_IO_CONF1_osc              (1U<<3)

    #define ST25R3911_REG_IO_CONF1_fifo_lt            (1U<<4)

    #define ST25R3911_REG_IO_CONF1_fifo_lt_32bytes        (0U<<4)

    #define ST25R3911_REG_IO_CONF1_fifo_lt_16bytes        (1U<<4)

    #define ST25R3911_REG_IO_CONF1_fifo_lr            (1U<<5)

    #define ST25R3911_REG_IO_CONF1_fifo_lr_64bytes        (0U<<5)

    #define ST25R3911_REG_IO_CONF1_fifo_lr_80bytes        (1U<<5)

    #define ST25R3911_REG_IO_CONF1_rfo2              (1U<<6)

    #define ST25R3911_REG_IO_CONF1_single             (1U<<7)

    Let me know what changes need to be made on these which are there in st25r3911_com.h ...

    Any other registers which we need to crosscheck kindly let us know.

    Thanks and regards

    Ravi

    RShiv.1Author
    Visitor II
    April 9, 2021

    Hi BT,

    changes made

    But we are seeing interrupt being generated once even without presenting our RFID ,after that when we present RFID we are not seeing the INT

    Technical Moderator
    April 9, 2021

    Hi Ravi,

    There is no need to change anything in st25r3911_com.h. Please do not modify it.

    There are a lot of interrupt conditions in the ST25R3911B so this is normal to have interrupts even without a tag being present in the field. As explained, the ST25R3911B is an RFID frontend so it signals to the MCU some conditions (such as  oscillator frequency is stable) through interrupt.

    Basically, the SPI and the interrupt are functional. You should be able to read a tag. If you do no succeed to read a tag, this means you probably have an antenna issue. This should be checked by your HW engineer.

    Rgds

    BT

    RShiv.1Author
    Visitor II
    April 20, 2021

    Hi BT,

    After connecting to antenna we are seeing following observations

    1. we are not seeing any waveform when we put demoini() function outside the while loop, basically antenna is not getting trigerred.
    2. when we put demoini() function inside the while loop then we are seeing antenna oscialltions regularly in every 2 sec once

    But we are not seeing any RFID value being read from the driver

    RShiv.1Author
    Visitor II
    April 20, 2021

    Hi BT,

    messages to UART

    RShiv.1Author
    Visitor II
    April 20, 2021

    Hi BT,

    These are finer oscillations as seen.

    let me know whether we need to change anything from software side in calling any function.Kindly let me know where the problem could be.

    If we keep demoini() function outsdie the loop then we are not seeing any oscillations...if antenna has any issue then we should not have seen anything when demoini is placed within the loop ..Kindly help us on this.

    regards

    Ravi

    Technical Moderator
    April 20, 2021

    Hi,

    demoIni() ***shall*** be outside the while(1) loop.

    Your problem seems to comes from the USER BUTTON which is always seen as low (thus the "Toggling wake up mode ON" message). Would you please comment out the Check if USER button is pressed code in the demo_cycle?

    // /*******************************************************************************/
    // /* Check if USER button is pressed */
    // if( platformGpioIsLow(PLATFORM_USER_BUTTON_PORT, PLATFORM_USER_BUTTON_PIN))
    // {
    // discParam.wakeupEnabled = !discParam.wakeupEnabled; /* enable/disable wakeup */
    // state = DEMO_ST_START_DISCOVERY; /* restart loop */
    // platformLog("Toggling Wake Up mode %s\r\n", discParam.wakeupEnabled ? "ON": "OFF");
     
    // /* Debounce button */
    // while( platformGpioIsLow(PLATFORM_USER_BUTTON_PORT, PLATFORM_USER_BUTTON_PIN) );
    // }

    Rgds

    BT

    RShiv.1Author
    Visitor II
    April 21, 2021

    Hi BT,

    I have made the changes you have mentioned still not getting the RFID..

    1.Demoini() is out of the while loop now

    2.I have commented the portion you have mentioned but it is not going inside the if loop

    if( rfalNfcIsDevActivated( rfalNfcGetState() ) )

          {

           platformLog("inside rfalNfcActivated\r\n");

            rfalNfcGetActiveDevice( &nfcDevice );

    I have attached the demo.c ..kindly let me know

    regards

    Ravi