cancel
Showing results for 
Search instead for 
Did you mean: 

ST25DV64KC What should be done as a setting about fast transfer mode?

KemalUzgoren
Associate III

Hi,

I want to use the Fast transfer mode on ST25DV64KC. I am using X-NUCLEO-NFC03A1 as a reader. When I write code for fast transform mode in X-NUCLEO-NFC03A1, I get an error. Do I need to make any adjustments in ST25DV64KC?

Rgds

KU

This discussion has been locked for participation. If you have a question, please start a new topic in order to ask your question
1 ACCEPTED SOLUTION

Accepted Solutions

Hello, 

As you already may have understood, ST25DV cannot be accessed at the same time from RF and from I2C.

For FTM, this has to be taken into consideration.
On I2C side, I recommend using the interrupt to synchronize on the RF. The interrupts RF_PUT_MSG and RF_GET_MSG are triggered when the RF has written or read a message. At this moment, the RF command has ended and the I2C can read the status registers and read or write the message in the mailbox.

On RF side, this is trickier as there is no interrupt possible. The RF reader must poll the status register MB_CTRL_Dyn to know if the I2C has read or write the message. This has to be done at with some temporization so that the I2C has finished reading or writing the message and is no more active so that there is no collision.
It can go from a few ms (5ms for example) up to several ms (may be 20 or 40ms) depending on the speed on the I2C side. This is very dependent on the implementation on the MCU side (MCU speed, FW, I2C bus speed etc.) so there is no generic value I can recommend. You have to experiment to find the value that is good for you.

Best regards.

 

View solution in original post

8 REPLIES 8
Ulysses HERNIOSUS
ST Employee

Hi,

did you look at

AN5633 Migrating from ST25DVxxK to ST25DVxxKC

and at


AN5916 Minimal migration path from ST25DVxxK to ST25DVxxKC ?

 

Best Regards, Ulysses

Brian TIDAL
ST Employee

Hi,

can you share more details about your issue: do you use your own implementation or do you use the ST RFAL source code? Can you also share the error returned and the SPI +IRQ traces?

Thanks

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.

Hi, 

I am developing my own application. As a reference, I read x-Nucleo-nfc03a, x-nucleo-nfc04a1 sample codes and other messages in STMicroelectronics community.

I wrote the code like this to write a message to the FTM region on the x-nucleo-nfc03a1 side;

err = rfalST25xVPollerPresentPassword(RFAL_NFCV_REQ_FLAG_DEFAULT, uid, ZONE_2, pwdArea2, SIZE(pwdArea2));

err = rfalST25xVPollerFastWriteMessage(RFAL_NFCV_REQ_FLAG_DEFAULT, uid, SIZE(wrData), wrData, txBuf, SIZE(txBuf));

I get the ERR_REQUEST macro as a return value as a result of the write operation. In the code shared in Community, rfalST25xVPollerWriteConfiguration, rfalST25xVPollerFastReadDynamicConfiguration, rfalST25xVPollerFastWriteDynamicConfiguration functions write between rfalST25xVPollerPresentPassword and rfalST25xVPollerFastWriteMessage.

I think it is used to activate FTM mode, but it returns ERR_PROTO value in these functions. The datasheet shows 0x0D as the pointer address value for FTM mode write and read configuration. I don't know what I need to give as input to rfalST25xVPollerWriteConfiguration and rfalST25xVPollerFastWriteDynamicConfiguration functions as register value.

When I examined the FTM example in x-nucleo-nfc03a1 sample codes, I could not see any code about rfalST25xVPollerWriteConfiguration, rfalST25xVPollerFastReadDynamicConfiguration, rfalST25xVPollerFastWriteDynamicConfiguration functions.

I am looking at the sample codes in x-nucleo-nfc04a1 in ST25DV64KC. I can't find any information on this side either. Is there a configuration for FTM mode or something I need to activate? I couldn't find much about ST25DV64KC.

Rgds

KU

Hi,

before using the FTM (Fast) Read/Write Message commands, the FTM has to be (i) authorized and (ii) enabled. (i) is done once by setting the MB_MODE to 1 in FTM static register (application should check the current value and set to 1 only in case it is 0 in order to avoid cycling the EEPROM). (ii) is done by writing MB_EN in MB_CTRL_Dyn register. The FTM can be reset to a known state by toggling MB_EN to 0 and then 1. Then rfalST25xVPoller(Fast)WriteMessage can be used. 

See the following example:

#define ST25DVxxKC_STATIC_REG_FTM                        0x0DU
#define ST25DVxxKC_STATIC_REG_FTM_MB_MODE_Pos            (0U)
#define ST25DVxxKC_STATIC_REG_FTM_MB_MODE_Msk            (0x01U << ST25DVxxKC_STATIC_REG_FTM_MB_MODE_Pos) 
#define ST25DVxxKC_STATIC_REG_FTM_MB_MODE_AUTHORIZED     ST25DVxxKC_STATIC_REG_FTM_MB_MODE_Msk
#define ST25DVxxKC_REG_MB_CTRL_DYN                       0x0DU
#define ST25DVxxKC_REG_MB_CTRL_DYN_MB_EN_Pos             (0U)
#define ST25DVxxKC_REG_MB_CTRL_DYN_MB_EN_Msk             (0x01U << ST25DVxxKC_REG_MB_CTRL_DYN_MB_EN_Pos)     
#define ST25DVxxKC_REG_MB_CTRL_DYN_MB_EN                 ST25DVxxKC_REG_MB_CTRL_DYN_MB_EN_Msk
#define ST25DVxxKC_PWD_NUM_0                             0

static void demoNfcv( rfalNfcvListenDevice *nfcvDev )
{
    ReturnCode            err;
    uint16_t              rcvLen;
    uint8_t               *uid; 
    uint8_t               reqFlag;
    static uint8_t        rxBuf1[259];
    static uint8_t        txBuf[300];
    uint8_t               msg[] = {0xCA, 0xFE, 0xDE, 0xCA};
    uint8_t               pwd[8] = {0, 0, 0, 0, 0, 0, 0, 0};
    uint8_t               reg;
              
    uid     = nfcvDev->InvRes.UID;
    reqFlag = RFAL_NFCV_REQ_FLAG_DEFAULT;
    
        /*
        * Activate selected state
        */
        err = rfalNfcvPollerSelect( reqFlag, nfcvDev->InvRes.UID );
        platformLog(" Select %s \r\n", (err != RFAL_ERR_NONE) ? "FAIL (revert to addressed mode)": "OK" );
        if( err == RFAL_ERR_NONE )
        {
            reqFlag = (RFAL_NFCV_REQ_FLAG_DEFAULT | RFAL_NFCV_REQ_FLAG_SELECT);
            uid     = NULL;
        }
        
    err = rfalST25xVPollerReadConfiguration(reqFlag, uid, ST25DVxxKC_STATIC_REG_FTM, &reg);
    platformLog(" rfalST25xVPollerReadConfiguration: %s 0x%x\r\n", (err != RFAL_ERR_NONE) ? "FAIL": "OK Data:", reg);
    if( err != RFAL_ERR_NONE )
    {
        return;
    }
    if( READ_BIT(reg, ST25DVxxKC_STATIC_REG_FTM_MB_MODE_AUTHORIZED) != ST25DVxxKC_STATIC_REG_FTM_MB_MODE_AUTHORIZED )
    {
        err = rfalST25xVPollerPresentPassword(reqFlag, uid, ST25DVxxKC_PWD_NUM_0, pwd, sizeof(pwd));
        platformLog(" rfalST25xVPollerPresentPassword: %s 0x%x\r\n", (err != RFAL_ERR_NONE) ? "FAIL": "OK Data:", reg);
        if( err != RFAL_ERR_NONE )
        {
            return;
        }  
        SET_BIT(reg, ST25DVxxKC_STATIC_REG_FTM_MB_MODE_AUTHORIZED);
        err = rfalST25xVPollerWriteConfiguration(reqFlag, uid, ST25DVxxKC_STATIC_REG_FTM, reg);
        platformLog(" rfalST25xVPollerWriteConfiguration: %s 0x%x\r\n", (err != RFAL_ERR_NONE) ? "FAIL": "OK Data:", reg);
        if( err != RFAL_ERR_NONE )
        {
            return;
        }        
    }
    err = rfalST25xVPollerWriteDynamicConfiguration(reqFlag, uid, ST25DVxxKC_REG_MB_CTRL_DYN, 0x00);
    platformLog(" rfalST25xVPollerWriteDynamicConfiguration: %s 0x%x\r\n", (err != RFAL_ERR_NONE) ? "FAIL": "OK Data:", reg);
    if( err != RFAL_ERR_NONE )
    {
        return;
    }
    err = rfalST25xVPollerWriteDynamicConfiguration(reqFlag, uid, ST25DVxxKC_REG_MB_CTRL_DYN, 0x01);
    platformLog(" rfalST25xVPollerWriteDynamicConfiguration: %s 0x%x\r\n", (err != RFAL_ERR_NONE) ? "FAIL": "OK Data:", reg);
    if( err != RFAL_ERR_NONE )
    {
        return;
    } 
    err = rfalST25xVPollerReadDynamicConfiguration(reqFlag, uid, ST25DVxxKC_REG_MB_CTRL_DYN, &reg);
    platformLog(" rfalST25xVPollerReadDynamicConfiguration: %s 0x%x\r\n", (err != RFAL_ERR_NONE) ? "FAIL": "OK Data:", reg);
    uint8_t msgLen = 0;
    
    err = rfalST25xVPollerReadMessageLength(reqFlag, uid, &msgLen);
    platformLog(" rfalST25xVPollerReadMessageLength: %s 0x%x\r\n", (err != RFAL_ERR_NONE) ? "FAIL": "OK Data:", msgLen);
    if( err != RFAL_ERR_NONE )
    {
        return;
    }
    
    if( msgLen != 0 )
    {
        rcvLen = 0;
        err = rfalST25xVPollerFastReadMessage(reqFlag, uid, 0, msgLen, rxBuf1, sizeof(rxBuf1), &rcvLen);
        platformLog(" rfalST25xVPollerReadMessage: %s %d %s\r\n", (err != RFAL_ERR_NONE) ? "FAIL": "OK Data:", err, hex2Str( &rxBuf1[0], rcvLen));
    }
    
    err = rfalST25xVPollerFastWriteMessage(reqFlag, uid, sizeof(msg) - 1, msg, txBuf, sizeof(txBuf));
    platformLog(" rfalST25xVPollerWriteMessage: %s %d %2.2x\r\n", (err != RFAL_ERR_NONE) ? "FAIL": "OK", err, rxBuf1[0]);
    if( err != RFAL_ERR_NONE )
    {
        return;
    }
    err = rfalST25xVPollerReadMessageLength(reqFlag, uid, &msgLen);
    platformLog(" rfalST25xVPollerReadMessageLength: %s 0x%x\r\n", (err != RFAL_ERR_NONE) ? "FAIL": "OK Data:", msgLen);
    if( err != RFAL_ERR_NONE )
    {
        return;
    }
    
    if( msgLen != 0 )
    {
        rcvLen = 0;
        err = rfalST25xVPollerFastReadMessage(reqFlag, uid, 0, msgLen, rxBuf1, sizeof(rxBuf1), &rcvLen);
        platformLog(" rfalST25xVPollerReadMessage: %s %d %s\r\n", (err != RFAL_ERR_NONE) ? "FAIL": "OK Data:", err, hex2Str( &rxBuf1[0], rcvLen));
    }
}

Make sure to use the selected state and make sure to have retry mechanism inside your application in case (Fast) Read/Write Message command are sent while the ST25DxxKC is busy on I2C interface (see interface arbitration inside the datasheet).

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.

Hi,

Thank you very much. Do I need to configure for an FTM mode on the ST25DV64KC side?

I also want to operate the ST2DV64KC with the antenna power of the X-Nucleo-NFC03A. So I want to use the energy harvesting mode. Do you have a suggestion? Because I cannot write to the protected area from X-Nucleo-NFC03A when the board with ST25DV64KC has 3.3 volts. I can write when there is no voltage on the ST25DV64KC. Do you have any suggestion about this issue?

Rgds

KU

JL. Lebon
ST Employee

Hello, 

The FTM mode requires the presence of power on the VCC pin.
So, if you want to do FTM when powering the tag only from energy harvesting, the VCC pin must be connected to the power rail powered from energy harvesting (basically connecting VEH to VCC).

"Because I cannot write to the protected area from X-Nucleo-NFC03A when the board with ST25DV64KC has 3.3 volts. I can write when there is no voltage on the ST25DV64KC."
-> I don't understand this question. There is no link between voltage and write protection. What do you mean by "I cannot write the protected area"?

Best regards.

Hi,

I've found the cause of your trouble. When I read the ST25DVxxKC datasheet, I can't use I2C when RF is full. I can't use RF when I2C is full. section 5.3 in the datasheet. This is where the problem comes from. RF and I2C are conflicting. In my process, while I am writing with RF, I am reading the block in I2C on the other side. How can I solve this problem. Can you help me with this issue?

Rgds

KU

Hello, 

As you already may have understood, ST25DV cannot be accessed at the same time from RF and from I2C.

For FTM, this has to be taken into consideration.
On I2C side, I recommend using the interrupt to synchronize on the RF. The interrupts RF_PUT_MSG and RF_GET_MSG are triggered when the RF has written or read a message. At this moment, the RF command has ended and the I2C can read the status registers and read or write the message in the mailbox.

On RF side, this is trickier as there is no interrupt possible. The RF reader must poll the status register MB_CTRL_Dyn to know if the I2C has read or write the message. This has to be done at with some temporization so that the I2C has finished reading or writing the message and is no more active so that there is no collision.
It can go from a few ms (5ms for example) up to several ms (may be 20 or 40ms) depending on the speed on the I2C side. This is very dependent on the implementation on the MCU side (MCU speed, FW, I2C bus speed etc.) so there is no generic value I can recommend. You have to experiment to find the value that is good for you.

Best regards.