problem with use HAL_FLASH_Program
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
2015-03-05 12:08 AM
Posted on March 05, 2015 at 09:08
when i use this function
uint8_t Save_data(void) { uint8_t idx; uint8_t addr; FLASH_EraseInitTypeDef erase; uint32_t pg_error; HAL_FLASH_Unlock(); erase.NbPages = 1; erase.PageAddress = ADDR_FLASH_PAGE_127; erase.TypeErase = FLASH_TYPEERASE_PAGES; if(HAL_FLASHEx_Erase(&erase,&pg_error)!= HAL_OK) { HAL_FLASH_Lock(); return 0; } addr=0; for(idx=0; idx <9 ; idx++) { if(HAL_FLASH_Program(FLASH_TYPEPROGRAM_HALFWORD,(uint32_t)(ADDR_FLASH_PAGE_127+addr),(uint64_t)param[idx])!= HAL_OK) { HAL_FLASH_Lock(); return 0; } addr++; } HAL_FLASH_Lock(); return 1; } my system going to HardFault_Handler and only write first byte of data to flash . please help me
This discussion is locked. Please start a new topic to ask your question.
1 REPLY 1
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
2017-12-28 5:44 AM
Posted on December 28, 2017 at 14:44
Hello,
I also had this problem. This post is old, but can be an issue still for other (like me).
In my case, I deleted flash area where my code was located. When it executed again, it got lost and thus, the hard fault.
It is important to check exactly the sectors that we need to erase.
