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 22, 2021

    Hi BT,

    to check SPI we know that SPI initialization print is working right(demoini)..atleast the start is fine..any other parameters to be checked there..we will see if we can get logic analyser ..

    I have added the code in dmeo.c do not what I have done is right or wrong based on akk req I gave 0x52 and 0xc based in *** platform..let me know

    ret1 = rfalNfcaPollerCheckPresence(0x52,0x0c);

        platformLog("return code %d\r\n",ret1);

    Let me whether this correct and where do I need to add the code..curretnly after adding dod not get any print..

    Let me if we have to enter the code where we need to debug and put the prints..do you have a document for this which explains so that we shall get some clue.

    thanks and regards

    Ravi

    RShiv.1Author
    Visitor II
    April 22, 2021

    Hi BT,

    I am getting return code 33

    Technical Moderator
    April 22, 2021

    Hi Ravi,

    my expectation was that you would have print the return code of rfalNfcaPollerCheckPresence inside this rfalNfcaPollerCheckPresence just before the return ret. Please do not modify the demo.c and revert your changes. Error 33 mean wrong state because you have added a call to rfalNfcaPollerCheckPresence in an unexpected place.

    /*******************************************************************************/
    ReturnCode rfalNfcaPollerCheckPresence( rfal14443AShortFrameCmd cmd, rfalNfcaSensRes *sensRes )
    {
     ReturnCode ret;
     uint16_t rcvLen;
     
     /* Digital 1.1 6.10.1.3 For Commands ALL_REQ, SENS_REQ, SDD_REQ, and SEL_REQ, the NFC Forum Device *
     * MUST treat receipt of a Listen Frame at a time after FDT(Listen, min) as a Timeour Error */
     
     ret = rfalISO14443ATransceiveShortFrame( cmd, (uint8_t*)sensRes, (uint8_t)rfalConvBytesToBits(sizeof(rfalNfcaSensRes)), &rcvLen, RFAL_NFCA_FDTMIN );
     if( (ret == ERR_RF_COLLISION) || (ret == ERR_CRC) || (ret == ERR_NOMEM) || (ret == ERR_FRAMING) || (ret == ERR_PAR) )
     {
     ret = ERR_NONE;
     }
     platformLog("rfalNfcaPollerCheckPresence return code %d\r\n",ret); // <------- JUST HERE ONLY
     return ret;
    }

    Once modified, compile/link/flash/execute and tell me the result.

    Rgds

    BT

    RShiv.1Author
    Visitor II
    April 22, 2021

    Hi BT,

    I have captured the print and sending in doc...since its pointing to wrong state

    #define ERR_WRONG_STATE          ((ReturnCode)33U) /*!< incorrent state for requested operation */

    what in demo.c needs to be changed so that I can configure correct state and get the values??

    Kindly help here as we are closer I guess.

    thanks and regards

    ravi

    RShiv.1Author
    Visitor II
    April 22, 2021

    Hi BT,

    I am getting retun code 4

    RShiv.1Author
    Visitor II
    April 22, 2021

    Hi BT,

    I am getting the return code 4 ..attached is the print what I got

    RShiv.1Author
    Visitor II
    April 22, 2021

    Hi BT,

    any clue what needs to be changed from here ..any H/W or S/w configuration.

    regards

    Ravi

    Technical Moderator
    April 22, 2021

    Hi,

    this means that the ST25R3911B has transmitted a REQA or WUPA message but has not received any answer from the tag (4 = ERR_TIMEOUT). Therefore the SW is properly working and the issue is:

    • Either your tag is dead ==> check that your tag is functional (e.g. use an NFC enable Android phone and read your tag)
    • or the reader antenna has an issue (wrong matching circuit, etc.) ==> check the HW with your HW engineer. If you need to prove that the SW is working, ask you HW engineer to connect a X-NUCLEO-NFC05A1 board on the SPI + IRQ +power supply instead of the ST25R3911B on your board (==> i.e. to use the ST25R3911B from the X-NUCLEO-NFC05A1 and its antenna and its matching circuit).

    Rgds

    BT

    RShiv.1Author
    Visitor II
    April 22, 2021

    Hi BT,

    Thanks for the reply..i will do this and update you and ping you if I need any pointers or help..thanks for all your support.

    regards

    Ravi

    RShiv.1Author
    Visitor II
    April 27, 2021

    Hi BT,

    As we were debugging the SPI ..we have connected the existing board with  X-NUCLEO-NFC05A1 board and checking for antenna ..this activity is going on..we will keep you posted once this works.

    Mean while I would like to know whether there is any simulator where I can write other application program and test for our application in C.Kindly let me know

    regards

    Ravi

    Technical Moderator
    April 27, 2021

    Hi Ravi,

    there is no simulation of ST25R3911B available. As indicated by Brian 3 messages above please use a cross-connected X-NUCLEO-NFC05A1 to be able do your SW development.

    Regards, Ulysses