RM0367
/* (3) Enter in wait for interrupt. The EOP check is done in the Flash ISR
/* (6) Reset the ERASE and DATA bits in the FLASH_PECR register
FLASH->PECR
*(__IO uint32_t *)addr
__WFI();
FLASH->PECR
A.3.7
Program Option byte code example
/**
* This function programs a 16-bit option byte and its complement word.
* Param None
* Retval None
*/
__INLINE __RAM_FUNC
{
/* (1) Write a 32-bit word value at the option byte address,
/* (3) Wait until the BSY bit is reset in the FLASH_SR register */
/* (4) Check the EOP flag in the FLASH_SR register */
/* (5) Clear EOP flag by software by writing EOP at 1 */
*(__IO uint32_t *)(OB_BASE
/* (1) */
while
{
/* For robust implementation, add here time-out management */
}
if
((FLASH->SR
{
FLASH->SR
}
else
{
/* Manage the error cases */
}
}
Note:
This function must be loaded in
A.3.8
Erase Option byte code example
/**
* This function erases a 16-bit option byte and its complement
word.
* Param None
*/
to disable the page erase */
|=
FLASH_PECR_ERASE
= (uint32_t)0;
/* (3) */
&=
~(FLASH_PECR_ERASE
void
the 16-bit data is extended with its compemented value */
& FLASH_SR_BSY) != 0)
((FLASH->SR
& FLASH_SR_EOP) != 0)
= FLASH_SR_EOP;
| FLASH_PECR_DATA;
/* (2) */
| FLASH_PECR_DATA);
OptionByteProg(uint8_t
+ index) =
(uint32_t)((~data
/* (2) */
/* (3) */
/* (4) */
RAM.
RM0367 Rev 7
Code examples
/* (1) */
/* (4) */
index,
uint16_t
data)
<< 16) | data);
977/1043
1020
Need help?
Do you have a question about the STM32L0x3 and is the answer not in the manual?