Skip to main content
toinhatminh
Visitor II
September 30, 2014
Question

Save user data in Backup domain

  • September 30, 2014
  • 1 reply
  • 689 views
Posted on September 30, 2014 at 06:34

Hello Pro,

I want to save my data in to backup domain to backup data when reset happen ( watch dog timer reset).

This is my code :

uint16_t domua;// I wan to save this data.

/* Configure the PVD Level to 2.9V */

      PWR_PVDLevelConfig(PWR_PVDLevel_2V2);

    /* Enable PWR and BKP clock */

   RCC_APB1PeriphClockCmd(RCC_APB1Periph_PWR | RCC_APB1Periph_BKP, ENABLE);

     /* Enable access backup and RTC */

      PWR_BackupAccessCmd(ENABLE);

domua=TIM_GetCounter(TIM2);//

            BKP_WriteBackupRegister(BKP_DR1, domua);// Back up data do mua.

            /***when watch dog timer  reset, domua=0, At this time, I want to back up this data*/

            if (domua==0){domua+=BKP_ReadBackupRegister(BKP_DR1);}

But it doesn't work as I wish.

Please help me point out what is going wrong ?

Thanks a lot,

Minh
    This topic has been closed for replies.

    1 reply

    chen
    Associate II
    October 1, 2014
    Posted on October 01, 2014 at 11:55

    Have you connected a battery for the back up domain?

    It will probably not work unless there is a battery connected.

    The documentation only implies this :

    ''Battery backup domain

    Backup domain description

    To retain the content of the RTC backup registers, backup SRAM, and supply the RTC when

    VDD is turned off, VBAT pin can be connected to an optional standby voltage supplied by a

    battery or by another source.

    To allow the RTC to operate even when the main digital supply (VDD) is turned off, the VBAT

    pin powers the following blocks:

    • The RTC

    • The LSE oscillator

    • The backup SRAM when the low-power backup regulator is enabled

    • PC13 to PC15 I/Os, plus PI8 I/O (when available)

    The switch to the VBAT supply is controlled by the power-down reset embedded in the Reset

    block.''

    ''Backup domain reset

    The backup domain reset sets all RTC registers and the RCC_BDCR register to their reset

    values. The BKPSRAM is not affected by this reset. The only way of resetting the

    BKPSRAM is through the Flash interface by requesting a protection level change from 1 to

    0.

    A backup domain reset is generated when one of the following events occurs:

    1. Software reset, triggered by setting the BDRST bit in the RCC Backup domain control

    register (RCC_BDCR).

    2. VDD or VBAT power on, if both supplies have previously been powered off.''