I am attempting to write some data to my stm32 discovery board (STM32F4VET11). Following the data sheet: (Sector 11, address 0x080E0000).
The code compiles, however, the write never takes place. When I enter debug mode and check rdBuf, the addresses hold 0x00.
Any tips?
//setup memory
HAL_FLASH_Unlock();
FLASH_Erase_Sector(11, FLASH_VOLTAGE_RANGE_3);
HAL_FLASH_Lock();
//write to memory
HAL_FLASH_Unlock();
uint8_t rdBuf[5];
uint8_t wrBuf[5] = {0x11, 0x22, 0x33, 0x44, 0x55};
uint32_t flashAddress = 0x080E0000;
for(uint32_t i=0; i<5; i++)
{
HAL_FLASH_Program(FLASH_TYPEPROGRAM_BYTE, flashAddress, ((uint8_t *)wrBuf)[i]);
flashAddress++;
}
HAL_FLASH_Lock();
//read
flashAddress = 0x080E0000;
for(uint32_t i=0; i<5; i++)
{
*((uint8_t *)rdBuf + i) = *(uint8_t *)flashAddress;
flashAddress++;
}