FLASH programming issue on HAL_FLASH_Unlock
Hi there!
I'm experiencing a new trouble: trying to program a simple flash Word it results in an hard fault; moreover, also trying to read the same area gives an hard fault.
Debugging the application I discovered that the HAL_FLASH_Unlock function fails.
Since I already seen sutch code work, it's quite strange to me!
b08t InitFLASHwrite(void)
{
/*.-.-.| Local variables: |.-.-.*/
b08t bIsError = FALSE; // Output error indication
HAL_StatusTypeDef enuUnlock = HAL_FLASH_Unlock(); // Unlock state
/*.-.-.| Execution: |.-.-.*/
// Unlock FLASH memory...
if(enuUnlock == HAL_OK)
{
// No errors:
__HAL_FLASH_CLEAR_FLAG(FLASH_FLAG_EOP | FLASH_FLAG_OPERR | FLASH_FLAG_WRPERR |
FLASH_FLAG_PGSERR | FLASH_FLAG_WRPERR); // Clear pending flags (if any)
// Needed after an update retry otherwise flash erase is not executed
__HAL_FLASH_CLEAR_FLAG(FLASH_FLAG_ALL_ERRORS_BANK1);
__HAL_FLASH_CLEAR_FLAG(FLASH_FLAG_ALL_ERRORS_BANK2);
}
else
{
bIsError = TRUE; // Else indicate error
printf("**** HAL_FLASH_Unlock() fail! ****\r\n");
}
return bIsError;
}
Above there is the code.
What's wrong?
iTTy
PS - Environment:
Nucleo-H755ZI-Q, Cube Ide 1.13.2, FW lib. 1.11.1, Cube MX 6.9.2
