2016-02-25 01:22 AM
Hello everyone!
I'm trying to store a user data in flash memory by the nexf source code #define FLASH_START_ADDR ((uint32_t)0x08000000) #define FLASH_END_ADDR ((uint32_t)0x0803FFFF) #define FLASH_PAGE_SIZE ((uint16_t)0x800) #define USER_DATA_START FLASH_END_ADDR- FLASH_PAGE_SIZE FLASH_EraseInitTypeDef EraseInit; uint64_t Data= 1; HAL_FLASH_Unlock(); EraseInit.NbPages= FLASH_BANK_1; EraseInit.PageAddress= (uint32_t)USER_DATA_START; EraseInit.TypeErase= FLASH_TYPEERASE_PAGES; EraseInit.NbPages= 1; HAL_FLASH_Unlock(); Rslt= HAL_FLASHEx_Erase(&EraseInit, &PageError); HAL_FLASH_Program(FLASH_TYPEPROGRAM_HALFWORD,USER_DATA_START, Data); // tracing from this line HAL_FLASH_Lock(); The program crushes inside FLAH_Program_HalfWord function at this line: SET_BIT(FLASH->CR, FLASH_CR_PG); // OK*(__IO uint16_t*)Address = Data; // Crushes2016-02-25 02:55 AM
The address you use can't be ODD. You should subtract whole pages from 0x08040000
2016-02-25 03:38 AM
Thanks for your reply clive1
The address for writting was odd really. Now it works