cancel
Showing results for 
Search instead for 
Did you mean: 

AN 2594 - cant read data back ...

finnb2
Associate II
Posted on July 14, 2010 at 10:36

AN 2594 - cant read data back ...

3 REPLIES 3
domen23
Associate II
Posted on May 17, 2011 at 13:58

You sure you are doing not just checking the return value, but called EE_ReadVariable with the correct pointer?

You didn't include any code, that's why the questions might be silly :p

finnb2
Associate II
Posted on May 17, 2011 at 13:58

Hey,

this is what i do ...

uint16_t VarValue = 0;

uint16_t data[600];

void EE(int argc, char *argv[])

{

      int n=0;

      argc=argc;

      if (0 == strcmp(argv[1], ''u''))

      {

          FLASH_Unlock();

      }

      if (0 == strcmp(argv[1], ''i''))

      {

          n = EE_Init();

          printf(''\nInit = %d\n'',n) ;

      }

      if (0 == strcmp(argv[1], ''w''))

      {

          for (VarValue = 0; VarValue < 50; VarValue++)

          {

            n = EE_WriteVariable(VirtAddVarTab[1], 100-VarValue);

            printf(''\nWr = %d\n'',n) ;

          }     

      }

      if (0 == strcmp(argv[1], ''r''))

      {

          n=EE_ReadVariable(VirtAddVarTab[1], data);

          printf(''\nRd = %d\n'',n) ;

          for (VarValue = 0; VarValue < 50; VarValue++)

          {

             printf(''%d -'',data[VarValue] ) ;

          }     

      }

}  

---

 

the array data[] contains zeros when i call the last paragraph.....

reg Finn

cnurton
Associate II
Posted on May 17, 2011 at 13:58

EEprom emulation, described in AN 2594 works OK. I have had it working on an STM32F100 micro. Here are a few things I have spotted from your code:

1.

      

Ensure you call the following in the correct order:

FLASH_Unlock();

EE_Init();

EE_WriteVariable

2.  You are not incrementing the address pointer of the array that you send to EE_ReadVariable, also when you call it only one int is returned. Then you try and print an array that has not been populated Try passing a pointer of a 16 bit int then load that into your array and call EE_ReadVariable in your for loop.

    if (0 == strcmp(argv[1], ''r''))

     {

          n=EE_ReadVariable(VirtAddVarTab[1], data);

          printf(''\nRd = %d\n'',n) ;

          for (VarValue = 0; VarValue < 50; VarValue++)

          {

             printf(''%d -'',data[VarValue] ) ;

          }     

      }

3.

      

VirtAddVarTab[1] is just one virtual address so every time you call EE_WriteVariable with VirtAddVarTab[1] you are updating different flash locations with the same virtual address.

        e.g.         1 = 100

                        1 = 99

                        1 = 98

                        1 = 97….. and so on

                         

 Then when you call EE_ReadVariable you will return the last VirtAddVarTab[1] updated in flash.

So you may want to increment the virtual address pointer. Hope this helps!