cancel
Showing results for 
Search instead for 
Did you mean: 

Fast transfer mode mailbox - how many write cycles can it handle?

EGiff
Associate III

I have an application which must send > 100KB/day to an RFID/NFC reader (I'm using the STM25R Disco) - for days and years on end.

Looking at the EEPROM spec, it's good for 600k write cycles at 85 °C

(That means even at 64Kbit EEPROM, wear leveling would be critical for long life.)

The Fast Transfer Mode buffer / mailbox is intriguing (256 Bytes) - it seems perfect for my use case - (mainly polling data) - however I cannot find any information about the type of memory used for this or number of write cycles it supports in the datasheet.

So, what type memory is used for this FTM mailbox? How many write cycles can it handle?

Thank you very much

33 REPLIES 33
EGiff
Associate III

Well, you can of course use the STEVAL-SMARTAG1 in EH mode without battery as is - but that board was more orientated toward logging temperatures in the EEPROM over a long time (using the battery) - later to be harvested using NFC and Smartphone.

As such - the STEVAL-SMARTAG1 does not contain specific methods to enable or use FTM mode.

That's why you would need to graph the methods from the ST25DV-Disco board - which has a number of FTM demos - to the STEVAL-SMARTAG1 code.

I'll see if I can find the modifications and send them to you.

Hello Evan:

Thanks very much!

EGiff
Associate III

Ok, in SmarTagNFC.c (and .h), you need to add this:

//EMG ported from ST25-DISCOVERY

NFCTAG_StatusTypeDef InitMailBoxMode( void )

{

 NFCTAG_StatusTypeDef ret = NFCTAG_OK;

 //Changing system registers from I2C and RF side both require a password

 //default password is 00 00 00 00 00 00 00 00

 ST25DV_PASSWD passwd;

 passwd.MsbPasswd = 0;

 passwd.LsbPasswd = 0;

 /* Present password to open session */

 ret = St25Dv_i2c_ExtDrv.PresentI2CPassword( passwd );

 if ( ret != NFCTAG_OK) return ret; //password failed, can't go any further

 //Configure GPO as RF_ACTIVITY interrupt

 //Since this is a real-time system, we only want fresh data

 //so we use RF_ACTIVITY instead of RF_GET_MSG_EN

 //and accept data loss if sample time is too slow

 //This exists but is not used by the driver

 //ST25DV_GPO gpo;

 //gpo.GPO_Enable = 1;

 //gpo.GPO_RFActivity_en = 1;

 //so we use hex

 uint16_t gpo = 0x82;

 ret = St25Dv_i2c_Drv.ConfigIT( gpo );

 if ( ret != NFCTAG_OK) return ret; //password failed, can't go any further

 //Should be A0 for RF_GET_MSG_EN

 /* If not activated, activate Energy Harvesting */

 ST25DV_EH_MODE_STATUS EH_mode = ST25DV_EH_ON_DEMAND;

 St25Dv_i2c_ExtDrv.ReadEHMode( &EH_mode);

 if( EH_mode != ST25DV_EH_ACTIVE_AFTER_BOOT )

 {

 /*

 EH_MODE, default: 1 (meaning only energy harvesting upon demand)

 0 (ST25DV_EH_ACTIVE_AFTER_BOOT): EH forced after boot

 1 (ST25DV_EH_ON_DEMAND): EH on demand only

 Set EH_MODE TO 0 to always start energy harvesting on boot (when a field is strong enough)

 "Writing 0 in EH_MODE at any time after boot will automatically set EH_EN bit to 1,

 and thus activate energy harvesting"

 Note: This should only ever happen after initial flash of firmware

 it can also be manually set from RF side

 */

 EH_mode = ST25DV_EH_ACTIVE_AFTER_BOOT;

 ret = St25Dv_i2c_ExtDrv.WriteEHMode( EH_mode );

 }

 if ( ret != NFCTAG_OK) return ret; //can't go any further

 ST25DV_EN_STATUS MB_mode = ST25DV_DISABLE;

 /* If not activated, activate Mailbox */

 St25Dv_i2c_ExtDrv.ReadMBMode( &MB_mode);

 if( MB_mode == ST25DV_DISABLE )

 {

MB_mode = ST25DV_ENABLE;

  ret =St25Dv_i2c_ExtDrv.WriteMBMode( MB_mode );

 }

 else

 {

  /* if already activated Clear MB content and flag */

  ret =St25Dv_i2c_ExtDrv.ResetMBEN_Dyn( );

  ret |=St25Dv_i2c_ExtDrv.SetMBEN_Dyn( );

 }

 /* Disable MB watchdog feature */

 ret |= St25Dv_i2c_ExtDrv.WriteMBWDG( 1 ); //Watch dog duration = 2(MB_WDG-1)x30ms±6, 4 = ~240ms, 1 = 60ms

 //ret |= St25Dv_i2c_ExtDrv.WriteMBWDG( 0 ); //Disable MB Watch Dog

 /* present wrong password for closing the session */

 passwd.MsbPasswd = ~passwd.MsbPasswd;

 passwd.LsbPasswd = ~passwd.LsbPasswd;

 St25Dv_i2c_ExtDrv.PresentI2CPassword( passwd );

 return ret;

}

/**

 * @brief DeInitializes the Mailbox mode, disables mailbox mode.

 * @param None No parameters.

 * @return NFCTAG_StatusTypeDef status.

 */

NFCTAG_StatusTypeDef DeInitMailBoxMode( void )

{

 return St25Dv_i2c_ExtDrv.ResetMBEN_Dyn( );

}

EGiff
Associate III

And in main.c,

// this will also set EH_EN to 1

NFCTAG_StatusTypeDef ret = NFCTAG_OK;

ret = InitMailBoxMode(); // enable FTM

EGiff
Associate III

Then you will need to watch interrupt on the GPO pin - which will be triggered when a mailbox message has been successfully read - meaning you can go ahead and write the next message

EGiff
Associate III

In main.c

/* USER CODE BEGIN 0 */

// Interrupt callback for ST25_GPO_Pin, indicating a message was read on RF side

// This assumes the GPO register is set correctly on the ST25DV

void HAL_GPIO_EXTI_Callback(uint16_t GPIO_Pin)

{

if (GPIO_Pin == ST25_GPO_Pin) {

GPO_Triggered = 1;

}

}

Hello evan:

Thanks! The codes you provide can work now.

johnson jiang
Associate II

Hi Evan:

Do you mean when i got GPO_Triggered, then i send one mailbox message?

like this:

[

if(GPO_Triggered) {

GPO_Triggered = 0;

NFCTAG_StatusTypeDef ret = NFCTAG_OK;

ST25DV_MB_CTRL_DYN_STATUS data = {0};

uint8_t send_data[4] ={'a','b','c','d'};

uint16_t len_send_data = 4;

/* Check if Mailbox is available */

ret = BSP_NFCTAG_GetExtended_Drv()->ReadMBctrl_Dyn( &data );

if( ret != NFCTAG_OK )

{

HAL_Delay(2);

return ret;

}

  

    ret = BSP_NFCTAG_GetExtended_Drv()->WriteMailboxData( send_data, len_send_data );

    if( ret != NFCTAG_OK )

{

HAL_Delay(2);

return ret;

}

  }

]

How can i trigeger it with the simplest way

EGiff
Associate III

If you look in the WriteMailboxData, it already checkes the registrer - and returns BUSY error if it's not available (which should never be the case since we got GPO interrpt).

I do it like this:

if (GPO_Triggered) { // interrupt from ST25DV indicating the mailbox is free

GPO_Triggered = 0; // handled

///some code

NFCTAG_StatusTypeDef status = St25Dv_i2c_ExtDrv.WriteMailboxData(txBuf, NFC_TX_BUFFER_LEN);

switch (status) {

case NFCTAG_OK:

// HAL_WWDG_Refresh(&hwwdg);

break;

case NFCTAG_BUSY:

// Reset RF missed message bit

status = St25Dv_i2c_ExtDrv.ResetMBEN_Dyn();

status |= St25Dv_i2c_ExtDrv.SetMBEN_Dyn();

// should not happen since we read the MB mode before attempting to write

break;

default:

// Perhaps time for a reset

break;

}

}

johnson jiang
Associate II

Hello evan:

Yes, got it.

Hi Lebon:

​I face another issue, by using ST25R-Disco (ST25R3911B) , how to set it work as long distance mode. 

Now the distance between ST25R-Disco (ST25R3911B) and STEVAL-SMARTAG1 is about 12cm. Can the distance be set longer, for example 30cm or 40 cm?

Thanks a lot!