Hi, I´ve been trying to write and read from Flash memory… but didn´t have enough results… so I hope you people could give me a hand…
Here´s the code I´m trying:
s8 memoria_flash;
static const ascii * flash_handle = "";
void atualiza_flash ( u8 id, ascii ** ParamStr, bool bWrite )
{
if ( bWrite )
{
if ( *ParamStr != NULL )
{
TRACE((1, ParamStr));
adl_flhWrite ( flash_handle, id, wm_strlen ( *ParamStr ) + 1, *ParamStr );
}
else
{
adl_flhErase ( flash_handle, id );
}
}
else
{
s32 Length = adl_flhExist ( flash_handle, id );
if ( Length >= 0 )
{
if ( *ParamStr != NULL )
{
adl_memRelease ( *ParamStr );
}
*ParamStr = adl_memGet ( Length );
adl_flhRead ( flash_handle, id, Length, *ParamStr );
}
}
}
Here´s the how I´m trying to write and read, calling the function above:
ascii word_test[30];
atualiza_flash ( 0, "Just a test", TRUE );
atualiza_flash(0,word_test,FALSE);
But word_test never receives the “Just a test” string…
Any ideas?
Best Regards,
Henrique
jan
2
Hi Henrique,
I’m not sure if that’s the problem, but I wouldn’t use an empty string for the flash handle…
static const ascii * flash_handle = "";
Also, the adl_flh*** functions do return error codes. Maybe you should look at those to determine if there was an error…
Best Regards,
Jan
Piedos
3
I think the error is with the ascii word_test[30];
you can’t use memGet or memRelease with an array
please use
ascii * word_test;
word_test = adl_memGet(30);
instead…
Following the two advices here´s the code:
word_test = adl_memGet(32);
atualiza_flash(0, "Testing a String", TRUE);
atualiza_flash(0,word_test,FALSE);
TRACE((1, gps_string));
But I can´t get TRACE response as: “Testing String”.
What might be wrong?
Best Regards,
Henrique
I replaced the Pointer programming with Global variables and everything is just fine now.
??? don´t know why didn´t worked… ???
I have one more question:
adl_flhGetIDCount() function retrieves the instant ID count, right?
Does the ID counts only for manual FLASH recording or ADL already uses this function internally?
I want to know because I´m trying to parse “FLASH ID Count + 1” as a parameter to the function I save the data.
Like:
atualiza_flash (adl_flhGetIDCount(flash_handle)+1, word_test,TRUE );
Before the line code above, I tryed to display the FLASH Count ID and it says : 1024.
But inside the “atualiza_flash()” function I once again displayed the “id” variable that came through the first parameter.
And now it says: “1”
Is there anything I should do?
Best Regards,
Henrique