cancel
Showing results for 
Search instead for 
Did you mean: 

RTC plausible

nachname
Associate II
Posted on November 05, 2010 at 10:55

RTC plausible

6 REPLIES 6
Posted on May 17, 2011 at 14:13

Store a magic number in the ALARM or BKP registers within the same power domain.

Use an RTC epoch several years in the past (1970, 1980, 2000) so it's pretty evident if it restarted.

Chances are the registers will keep retaining long after the clock stops ticking.

Use some thresholding of the VBAT voltage and use the TAMPER pin.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
nachname
Associate II
Posted on May 17, 2011 at 14:13

It looks like it's not possible with this HW configuration and the STM32 has no useable internal function to detect the low Vbat voltage.

But it's still interesting at what voltage will the Tamper Event will happen.

Perhaps Vbat = 1.8V and Vdd = 3.6V at power up... this looks like trouble

The following HW changes seem to be an good approach (came from an other forum, thanks to A. K. (prx)):

Output-Pin --- R --- ADC-Pin --- >| --- Vbat

After power up, the Output-Pin begin to charge the goldcap through the resistor and immediately after doing this an ADC measurement is done (GoldCap Voltage + V_diode).

There's only trouble when the goldcap is not fitted or defect (open).

nachname
Associate II
Posted on May 17, 2011 at 14:13

Here's my unterstanding of what todo (that's a good hint with the tamper pin):

- Configure TAMPER Pin for transition 1->0

  (Reference Manual STM32F107 v11 PDF S. 74:

   Note: Tamper detection is still active when VDD power is switched off. To avoid unwanted resetting of the data backup registers, the TAMPER pin should be externally tied to the correct level.)

- So on the next startup I have to check if the BKP registers are cleared (I don't think an tamper interrupt flag is set, when no Vdd power is available to the microcontroller.)

- At what voltage will the tamper event happen ?

  when Standard I/O input low level voltage is [0.28 * (Vdd - 2)+0.8] = ? (=0.24 (with Vdd = 0))

  (Datasheet STM32F107 v5 PDF S. 54)

  It should happen at 1.8 V (spec. RTC+BKP domain)

- If my understanding is correct I don't have to write magic number to the BKP registers.

- I will try this on monday and report back

nachname
Associate II
Posted on May 17, 2011 at 14:13

What voltage at the Tamper Pin trigger an action (clear BKP register) ?

Ok, the BKP register are cleared when the microcontroller ''Vcc = 0V'' and the tamper pin is configured.

My last problem is the voltage when this event happen.

Sometimes the BKP register are not cleared when ''Vbat < 1.6 V'', other times the register is cleared at ''Vbat = 2.4 V''.

I can reproduce the reset of the backup registers with Vbat = 2.4V (oscilloscope attached, no spikes).

The goldcap is directly connected to Vbat and indirectly across a 100k resistor to the tamper pin (same result, when connected direct to Vbat).

Here some lines of code to describe (base was the BKP/Tamper example from the library):

[CODE]

#if 1

    uint16_t u16_bkp_temp = 0;

    /* Enable PWR and BKP clock */

    RCC_APB1PeriphClockCmd(RCC_APB1Periph_PWR | RCC_APB1Periph_BKP, ENABLE);

    /* Enable write access to Backup domain */

    PWR_BackupAccessCmd(ENABLE);

    u16_bkp_temp = BKP_ReadBackupRegister(BKP_DR16);

   

    printf(''backup register %X\n'', u16_bkp_temp);

   

    if(u16_bkp_temp == 0x5A) {

        setLED(LED4, GREEN);

        setLED(LED3, OFF);

    }

    else {

        u16_bkp_temp = 0x5A;

        BKP_WriteBackupRegister(BKP_DR16, u16_bkp_temp);

        u16_bkp_temp = 0;

        u16_bkp_temp = BKP_ReadBackupRegister(BKP_DR16);

       

        printf(''backup register (read back) %X\n'', u16_bkp_temp);

       

       

        setLED(LED4, OFF);

        setLED(LED3, RED);

    }

    /* Disable Tamper pin */

    BKP_TamperPinCmd(DISABLE);

    /* Disable Tamper interrupt */

    BKP_ITConfig(DISABLE);

    /* Tamper pin active on low level */

    BKP_TamperPinLevelConfig(BKP_TamperPinLevel_Low);

    /* Clear Tamper pin Event(TE) pending flag */

    BKP_ClearFlag();

    /* Enable Tamper pin */

    BKP_TamperPinCmd(ENABLE);   

#endif

[/CODE]

Posted on May 17, 2011 at 14:13

What voltage at the Tamper Pin trigger an action (clear BKP register) ?

I wouldn't try to use some voltage divider across the Vbat supply to drive the tamper pin.

Like I said, you need the threshold the Vbat voltage. You'll need an ultra low power supervisor circuit, which will consume very little current, and that will clamp the Tamper pin to the floor as soon as the battery/supercap voltage drops below a threshold you define (ie one that still permits the CPU to perform the tamper/clear action, but will soon be depleted, at least 1.8V). At below 1.8V you get into undefined operation, the CMOS cells will likely retain, and the OSC may or may not oscillate. The other benefit of using a real supervisor is that it will continue to clamp the tamper for a pre-determined period after the supplies, or cap, come back.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
nachname
Associate II
Posted on May 17, 2011 at 14:13

The supervisor circuit is a good solution.

I also tried to detect the RCC_FLAG_LSERDY at startup (when SET already: Ok) but this method doesn't work.

I'll stick to the solution with ADC conversion (described earlier) because of the attractive price.

Thanks clive1