Skip to content

STM32L4: clear error programming flags before erase & program operations #8263

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Oct 9, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions targets/TARGET_STM/TARGET_STM32L4/flash_api.c
Original file line number Diff line number Diff line change
Expand Up @@ -137,8 +137,9 @@ int32_t flash_erase_sector(flash_t *obj, uint32_t address)
return -1;
}

/* Clear OPTVERR bit set on virgin samples */
__HAL_FLASH_CLEAR_FLAG(FLASH_FLAG_OPTVERR);
/* Clear error programming flags */
__HAL_FLASH_CLEAR_FLAG(FLASH_FLAG_ALL_ERRORS);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you clear all flash error, maybe you can remove next __HAL_FLASH_CLEAR_FLAG ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be OK now. FLASH_FLAG_ALL_ERRORS includes also FLASH_FLAG_OPTVERR


/* Get the 1st page to erase */
FirstPage = GetPage(address);
/* MBED HAL erases 1 page / sector at a time */
Expand Down Expand Up @@ -194,6 +195,9 @@ int32_t flash_program_page(flash_t *obj, uint32_t address,
return -1;
}

/* Clear error programming flags */
__HAL_FLASH_CLEAR_FLAG(FLASH_FLAG_ALL_ERRORS);

/* Program the user Flash area word by word */
StartAddress = address;

Expand Down