strlen flash writing question.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2017-11-19 6:04 PM
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;
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2017-11-19 6:43 PM
Then use sizeof() or compute rather than assign.
ie
uint32_t WordCount1, WordCount2;
WordCount1 = (strlen(str1) + 3) / 4; // 32-bit words in string
WordCount2 = (strlen(str2) + 3) / 4; // 32-bit words in string
Up vote any posts that you find helpful, it shows what's working..
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2017-11-19 10:40 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2017-11-19 10:51 PM
Put it within the same compound statement you have the while() loops sitting in
Up vote any posts that you find helpful, it shows what's working..
