AnsweredAssumed Answered

strlen flash writing question.

Question asked by Study Yahoo on Nov 20, 2017
Latest reply on Nov 20, 2017 by Study Yahoo

In the flash memory as shown in the following code, the str1 and str2 values are divided into 4 bytes
I want to write down. I have an error like the image I captured .;

When I have an event, I write it to Flash and try to read it.

Help me ioi ;;

 

 

 

#define Address     ((uint32_t)0x08008000) /* Base @ of Sector 2, 16 Kbytes */
char str1[] = " 2017-11-09 09:32";
uint32_t *p1 = (uint32_t *)str1;
char str2[] = "Errorcode1";
uint32_t *p2 = (uint32_t *)str2;
uint32_t WordCount1 = (strlen(str1) + 3) / 4; // 32-bit words in string
uint32_t WordCount2 = (strlen(str2) + 3) / 4; // 32-bit words in string
while (WordCount1--)
{
if (HAL_FLASH_Program(FLASH_TYPEPROGRAM_WORD, Address, *p1++) == HAL_OK)
{
Address = Address + 4;
}
}
while (WordCount2--)
{
if (HAL_FLASH_Program(FLASH_TYPEPROGRAM_WORD, Address, *p2++) == HAL_OK)
{
Address = Address + 4;
}
}

 

 

Outcomes