2021-05-28 06:06 AM
How to store more than one 32 bit variable in eeprom memory in while loop and also to receive downlink?
Here,I have attached the code too.
Solved! Go to Solution.
2021-05-28 06:26 AM
I could not open the code you posted, but take in count that a programming takes 6 ms if not writing on already erased location.
If you need shorter write times: prepare the locations in advance by erasing them and write your data in blocks (64 bytes). A block write is just as fast as a byte/word write.
2021-05-28 06:26 AM
I could not open the code you posted, but take in count that a programming takes 6 ms if not writing on already erased location.
If you need shorter write times: prepare the locations in advance by erasing them and write your data in blocks (64 bytes). A block write is just as fast as a byte/word write.
2021-05-28 06:54 AM
Hi Cristian Gyorgy,
This is the main code
int main( void )
{
LoRaMacPrimitives_t LoRaMacPrimitives;
LoRaMacCallback_t LoRaMacCallbacks;
MibRequestConfirm_t mibReq;
BoardInitMcu( );
BoardInitPeriph( );
Flash_setup();
DeviceState = DEVICE_STATE_INIT;
printf("ClassA app start\r\n");
count = FLASH_ReadByte(0x1002);
count <<= 8;
count |= FLASH_ReadByte(0x1003);
count <<= 8;
count |= FLASH_ReadByte(0x1004);
count <<= 8;
count |= FLASH_ReadByte(0x1005);
count1 = FLASH_ReadByte(0x1006);
count1 <<= 8;
count1 |= FLASH_ReadByte(0x1007);
count1 <<= 8;
count1 |= FLASH_ReadByte(0x1008);
count1 <<= 8;
count1 |= FLASH_ReadByte(0x1009);
Count_Read = count;
Count1_Read = count1;
printf("Count_Read:%lu\n",Count_Read);
printf("Count1_Read:%lu\n",Count1_Read);
while( 1 )
{
if(joined_finish==1)
{
count++;
count1++;
FLASH_Unlock(FLASH_MemType_Data);
FLASH_ProgramByte(0x1002, count>>24);
FLASH_ProgramByte(0x1003, count>>16);
FLASH_ProgramByte(0x1004, count>>8);
FLASH_ProgramByte(0x1005, count);
FLASH_ProgramByte(0x1006, count1>>24);
FLASH_ProgramByte(0x1007, count1>>16);
FLASH_ProgramByte(0x1008, count1>>8);
FLASH_ProgramByte(0x1009, count1);
FLASH_Lock(FLASH_MemType_Data);
}
// here it comes switch case statement
}
2021-05-28 08:31 AM
FLASH_ProgramByte(0x1002, count>>24);
FLASH_ProgramByte(0x1003, count>>16);
FLASH_ProgramByte(0x1004, count>>8);
FLASH_ProgramByte(0x1005, count);
FLASH_ProgramByte(0x1006, count1>>24);
FLASH_ProgramByte(0x1007, count1>>16);
FLASH_ProgramByte(0x1008, count1>>8);
FLASH_ProgramByte(0x1009, count1);
Every line in the code above will take 6 ms: 8x6=48 ms programming time.
Instead you could do only 2 writes, by writing only 2 4-byte words (at a word aligned address!): 2x6=12 ms,
Or, read first the block where you want to do the write into SRAM, fill in the 8 bytes and than write the 64/128 bytes block back in only 6ms.
I don't know your compiler, what function has defined for the word/block programming, but for sure it has one.
2021-05-28 09:34 AM
Ya. Thank you. It is worked by using word. Downlink is also working and storing also happening.