2015-07-22 09:20 AM
I need to disable the VVDA monitor at power down reset (PDR).
To do this, it needs to write in the option bytes register. I did the following code.
//Disable VDDA MONITOR in option bit
uint8_t UserByte = FLASH_OB_GetUser(); //Rea the user option bytes
//Check VVDA is not yet cleared
if ( (UserByte & OB_VDDA_ANALOG_ON) != 0 )
{
FLASH_Status status = FLASH_OB_VDDAConfig(OB_VDDA_ANALOG_OFF);
if ( status == FLASH_COMPLETE )
{
FLASH_OB_Launch(); //Write to OB register and reset --> issue always doing the reset
}
}
The issue is that the bit VDDA of FLASH->OBR register is never cleared so it seems that the VVDA can not be cleared for unknown reason.
Any idea to solve the issue?
2015-07-22 09:36 AM
Any idea to solve the issue?
Do you unlock the FLASH and OB anywhere?Do you clear any error/status flags pending?Do you erase the OB anywhere?2015-07-22 10:38 AM
Since power is failing how do you guarantee the IC will have sufficient voltage and time to erase and reprogram the flash OB? Maybe it isn't cleared because the processor has stopped or faulted because voltage is too low.
Have you considered the lifetime limitations of constantly erasing flash every time the part is turned off? Jack Peacock2015-07-23 03:58 AM
Thanks for your advices.
Now it's work. Below the working code.//Disable VDDA MONITOR in option bit, to avoid Power Down Reset when VDDA is going down, only VDD is needed
uint8_t UserByte = FLASH_OB_GetUser();
if ( (UserByte & OB_VDDA_ANALOG_ON) != 0 )
{
FLASH_Unlock(); //CR.bitLock = 1 -> 0 OK
FLASH_OB_Unlock(); //CR.BitOPTWRE=1 (Write enable) needed before FLASH_OB_Erase()
FLASH_Status status = FLASH_OB_Erase();
if ( status == FLASH_COMPLETE )
{
status = FLASH_OB_VDDAConfig(OB_VDDA_ANALOG_OFF); //CR.BitOPTWRE=1 (Write enable); SR = 0; CR.BitOPTPG=1 (Option byte programming); SR.BitPGERR =0 (No Programming Error) OK
if ( status == FLASH_COMPLETE )
{
FLASH_OB_Launch(); //Write to OB register and reset
}
}
FLASH_OB_Lock();
FLASH_Lock();
}