cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F303RE: VDDA_MONITOR config

laurentwawrzyniak9
Associate II
Posted on July 22, 2015 at 18:20

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?
3 REPLIES 3
Posted on July 22, 2015 at 18:36

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?

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
jpeacock
Associate III
Posted on July 22, 2015 at 19:38

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 Peacock

laurentwawrzyniak9
Associate II
Posted on July 23, 2015 at 12:58

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();
}