Skip to content

Commit 17762b4

Browse files
authored
Merge pull request #8263 from juhoeskeli/flash_api_stm32l4
STM32L4: clear error programming flags before erase & program operations
2 parents 18d6131 + f7a030e commit 17762b4

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

targets/TARGET_STM/TARGET_STM32L4/flash_api.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -137,8 +137,9 @@ int32_t flash_erase_sector(flash_t *obj, uint32_t address)
137137
return -1;
138138
}
139139

140-
/* Clear OPTVERR bit set on virgin samples */
141-
__HAL_FLASH_CLEAR_FLAG(FLASH_FLAG_OPTVERR);
140+
/* Clear error programming flags */
141+
__HAL_FLASH_CLEAR_FLAG(FLASH_FLAG_ALL_ERRORS);
142+
142143
/* Get the 1st page to erase */
143144
FirstPage = GetPage(address);
144145
/* MBED HAL erases 1 page / sector at a time */
@@ -194,6 +195,9 @@ int32_t flash_program_page(flash_t *obj, uint32_t address,
194195
return -1;
195196
}
196197

198+
/* Clear error programming flags */
199+
__HAL_FLASH_CLEAR_FLAG(FLASH_FLAG_ALL_ERRORS);
200+
197201
/* Program the user Flash area word by word */
198202
StartAddress = address;
199203

0 commit comments

Comments
 (0)