Skip to content

Commit 3a6b52f

Browse files
author
Juho Eskeli
committed
Clear error programming flags before erase & program operations
1 parent ac6ca73 commit 3a6b52f

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

targets/TARGET_STM/TARGET_STM32L4/flash_api.c

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

140+
/* Clear error programming flags */
141+
__HAL_FLASH_CLEAR_FLAG(FLASH_FLAG_ALL_ERRORS);
142+
140143
/* Clear OPTVERR bit set on virgin samples */
141144
__HAL_FLASH_CLEAR_FLAG(FLASH_FLAG_OPTVERR);
142145
/* Get the 1st page to erase */
@@ -194,6 +197,9 @@ int32_t flash_program_page(flash_t *obj, uint32_t address,
194197
return -1;
195198
}
196199

200+
/* Clear error programming flags */
201+
__HAL_FLASH_CLEAR_FLAG(FLASH_FLAG_ALL_ERRORS);
202+
197203
/* Program the user Flash area word by word */
198204
StartAddress = address;
199205

0 commit comments

Comments
 (0)