STM32F439ZI first embedded flash program issue
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2022-06-23 6:43 AM
Hi,
I'm working with STM32F439ZI MCU. I setted system clock 180 MHz and as Reference Manual (RM0090) says I did:
-- VOS[1:0] = 0x11
-- over drive mode enabling
-- 5 WS latency (6 CPU cycles)
When I try to program something the first time after power up, it failes. Only the sector erase is good. The strange is that from the second time on, all operations are goods. I can correctly erase, program and read. I post my code:
void my_func(void)
{
HAL_FLASH_Unlock();
FLASH_EraseInitTypeDef EraseInitStruct;
EraseInitStruct.TypeErase = FLASH_TYPEERASE_SECTORS;
EraseInitStruct.VoltageRange = FLASH_VOLTAGE_RANGE_3;
EraseInitStruct.Sector = COM_CONFIG_SECTOR;
EraseInitStruct.NbSectors = 1;
uint32_t SECTORError = 0;
HAL_StatusTypeDef ret = HAL_FLASHEx_Erase(&EraseInitStruct, &SECTORError);
{
ret += HAL_FLASH_Program(FLASH_TYPEPROGRAM_BYTE, COM_CONFIG_BASE_ADDR + i), _comConfig.ucDhcpEnable);
HAL_FLASH_Lock();
}
How is it possible? Why does the first time it fail? Please could you help me? Thank you.
Best regards,
Antonio
- Labels:
-
STM32F4 Series
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2022-06-23 6:47 AM
Check and clear any pending error/status held in the status register.
Perhaps read and print values so you can observe behaviour without a debugger attached.
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
‎2022-06-23 7:09 AM
Ok I'll try it. Than you.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2022-06-27 7:42 AM
Hi tried and everytime it fails flash status register is all 0s. Any other suggestion? Thank you.
