2018-07-04 04:03 AM
Hi,
Using STM32L476QE
I get HAL_ERROR running the following code only when writing or erasing (page) at address 0x0803F800, doing the same with address 0x08040000 works fine.
both addresses are erased before the code executes.
my application runs from bank 1 (
0x0803F800 is the last page at bank 1)
there is no code at 0x0803F800 address.
ideas?
static FLASH_EraseInitTypeDef erase_init;
static uint32_t page_error; volatile static uint8_t status = 0; volatile HAL_StatusTypeDef result;HAL_FLASH_Unlock();
__HAL_FLASH_CLEAR_FLAG(FLASH_FLAG_ALL_ERRORS);
__disable_interrupt();// I tried with and without this line
//All the following fails
result = HAL_FLASH_Program(FLASH_TYPEPROGRAM_DOUBLEWORD, 0x0803F800, 0x1234567890124356); if (result == HAL_OK) if (*(uint64_t *)0x0803F800 == 0x1234567890124356) status = 1; else status = 0; erase_init.TypeErase = FLASH_TYPEERASE_PAGES; erase_init.Banks = GetBank(0x0803F800); //should be 1 erase_init.Page = GetPage(0x0803F800); //should be 127 erase_init.NbPages = 1;if (HAL_FLASHEx_Erase(&erase_init, &page_error) != HAL_OK)
status = 0; else status = 1;//All the following works
__HAL_FLASH_CLEAR_FLAG(FLASH_FLAG_ALL_ERRORS);if (HAL_FLASH_Program(FLASH_TYPEPROGRAM_DOUBLEWORD, 0x08040000,
0x1234567890124356) == HAL_OK) if (*(uint64_t *)0x08040000 == 0x1234567890124356) status = 1; else status = 0; erase_init.TypeErase = FLASH_TYPEERASE_PAGES; erase_init.Banks = GetBank(0x08040000); //should be 2 erase_init.Page = GetPage(0x08040000); //should be 256 erase_init.NbPages = 1;if (HAL_FLASHEx_Erase(&erase_init, &page_error) != HAL_OK)
status = 0; else status = 1;HAL_FLASH_Lock();
while(1);
#page-erase #flash-programming #stm32l42018-08-10 09:17 AM
Sorry, bumping old zombie unanswered threads off my feed
Do long constants require L suffix.
Seems like a group of related threads that could probably be merged
2018-08-12 12:43 AM
I'm not sure, but writing long as it is in the code to 0x08040000 works