cancel
Showing results for 
Search instead for 
Did you mean: 

How to increase number of variables for EEprom emulation of STM32F2

toantq3
Associate II
Posted on September 12, 2012 at 11:25

Dear friends,

I'm using the eeprom emulation STM32F2xx_AN3390_FW_V1.0.0 for saving the configuraiton. I make some test code to understand the source code, I can test with 3 varibles with address 0x5555, 0x6666, 0x7777. But after I increase NB_OF_VAR             ((uint8_t)0x05) and my souce code testing below. I read the value of address 0x8888 and 0x9999 are always zeros. I was wondering that friends can give me a helpl

uint16_t VirtAddVarTab[NB_OF_VAR] = {0x5555, 0x6666, 0x7777, 0x8888, 0x9999};

void EE_Test(void)

{

u8 buff[5];

/* Store 0x1000 values of Variable1 in EEPROM */

for (VarValue = 0x1000; VarValue <= 0x100F; VarValue++)

{

EE_WriteVariable(VirtAddVarTab[0], VarValue);

}

/* read the last stored variables data*/

EE_ReadVariable(VirtAddVarTab[0], &VarDataTab[0]);

uart_tx_puts(EZ_HMI_COM, uart_tx_get_buf_ptr(EZ_HMI_COM), ''BYTE 1'', 1);

x16_to_str(VarDataTab[0], buff);

uart_tx_puts(EZ_HMI_COM, uart_tx_get_buf_ptr(EZ_HMI_COM), buff, 1);

/* Store 0x2000 values of Variable2 in EEPROM */

for (VarValue = 0x2000; VarValue <= 0x200F; VarValue++)

{

EE_WriteVariable(VirtAddVarTab[1], VarValue);

}

/* read the last stored variables data*/

EE_ReadVariable(VirtAddVarTab[0], &VarDataTab[0]);

EE_ReadVariable(VirtAddVarTab[1], &VarDataTab[1]);

uart_tx_puts(EZ_HMI_COM, uart_tx_get_buf_ptr(EZ_HMI_COM), ''BYTE 1/2'', 1);

x16_to_str(VarDataTab[0], buff);

uart_tx_puts(EZ_HMI_COM, uart_tx_get_buf_ptr(EZ_HMI_COM), buff, 1);

x16_to_str(VarDataTab[1], buff);

uart_tx_puts(EZ_HMI_COM, uart_tx_get_buf_ptr(EZ_HMI_COM), buff, 1);

/* Store 0x3000 values of Variable3 in EEPROM */

for (VarValue = 0x3000; VarValue <= 0x300F; VarValue++)

{

EE_WriteVariable(VirtAddVarTab[2], VarValue);

}

/* read the last stored variables data*/

EE_ReadVariable(VirtAddVarTab[0], &VarDataTab[0]);

EE_ReadVariable(VirtAddVarTab[1], &VarDataTab[1]);

EE_ReadVariable(VirtAddVarTab[2], &VarDataTab[2]);

uart_tx_puts(EZ_HMI_COM, uart_tx_get_buf_ptr(EZ_HMI_COM), ''BYTE 1/2/3'', 1);

x16_to_str(VarDataTab[0], buff);

uart_tx_puts(EZ_HMI_COM, uart_tx_get_buf_ptr(EZ_HMI_COM), buff, 1);

x16_to_str(VarDataTab[1], buff);

uart_tx_puts(EZ_HMI_COM, uart_tx_get_buf_ptr(EZ_HMI_COM), buff, 1);

x16_to_str(VarDataTab[2], buff);

uart_tx_puts(EZ_HMI_COM, uart_tx_get_buf_ptr(EZ_HMI_COM), buff, 1);

/* Store 0x4000 values of Variable3 in EEPROM */

for (VarValue = 0x1000; VarValue <= 0x100F; VarValue++)

{

EE_WriteVariable(VirtAddVarTab[3], VarValue);

}

uart_tx_puts(EZ_HMI_COM, uart_tx_get_buf_ptr(EZ_HMI_COM), ''BYTE 1/2/3/4'', 1);

x16_to_str(VarDataTab[0], buff);

uart_tx_puts(EZ_HMI_COM, uart_tx_get_buf_ptr(EZ_HMI_COM), buff, 1);

x16_to_str(VarDataTab[1], buff);

uart_tx_puts(EZ_HMI_COM, uart_tx_get_buf_ptr(EZ_HMI_COM), buff, 1);

x16_to_str(VarDataTab[2], buff);

uart_tx_puts(EZ_HMI_COM, uart_tx_get_buf_ptr(EZ_HMI_COM), buff, 1);

x16_to_str(VarDataTab[3], buff);

uart_tx_puts(EZ_HMI_COM, uart_tx_get_buf_ptr(EZ_HMI_COM), buff, 1);

/* Store 0x5000 values of Variable3 in EEPROM */

for (VarValue = 0x1000; VarValue <= 0x100F; VarValue++)

{

EE_WriteVariable(VirtAddVarTab[4], VarValue);

}

uart_tx_puts(EZ_HMI_COM, uart_tx_get_buf_ptr(EZ_HMI_COM), ''BYTE 1/2/3/4/5'', 1);

x16_to_str(VarDataTab[0], buff);

uart_tx_puts(EZ_HMI_COM, uart_tx_get_buf_ptr(EZ_HMI_COM), buff, 1);

x16_to_str(VarDataTab[1], buff);

uart_tx_puts(EZ_HMI_COM, uart_tx_get_buf_ptr(EZ_HMI_COM), buff, 1);

x16_to_str(VarDataTab[2], buff);

uart_tx_puts(EZ_HMI_COM, uart_tx_get_buf_ptr(EZ_HMI_COM), buff, 1);

x16_to_str(VarDataTab[3], buff);

uart_tx_puts(EZ_HMI_COM, uart_tx_get_buf_ptr(EZ_HMI_COM), buff, 1);

x16_to_str(VarDataTab[4], buff);

uart_tx_puts(EZ_HMI_COM, uart_tx_get_buf_ptr(EZ_HMI_COM), buff, 1);

}

2 REPLIES 2
Posted on September 12, 2012 at 17:01

I read the value of address 0x8888 and 0x9999 are always zeros.

Your supplied code does not read them back.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
toantq3
Associate II
Posted on September 27, 2012 at 04:05