RA6: how to detect VBAT drop-outs?

How can I detect a temporary VBAT power loss during VCC power off?

Background: I need to detect e.g. a previous battery change after the device is powered again (coming out of reset).

  • In my experience this is done with energy reserve (e.g. capacitor) added to MCU, and resistor divider network connected to ADC pin where VBAT can be monitored.  Upon detection of low VBAT, need the energy reserve to last long enough for the MCU to do its housekeeping that might be required and gracefully shut down.

  • Hi Jim,

    thanks for you reply.

    The problem I see with your proposal is that VBAT cannot be monitored via ADC while the MCU is not powered.

    The device can be switched off for days or even weeks. When switched on again I need to know if the RTC and backup RAM have been properly supplied during power-off.

    Your suggestion with an additional capacitor is valuable as it can help avoid a drop-out during battery change. But it is only "half the solution" I am looking for. It would be good to have a status bit somewhere in the RTC section that would flag an intermediate drop-out

    Cheers,
    Ralf

  • Hello,

    When VBATTMNSELR.VBATTMNSEL = 1 the VBATTMON bit indicates if VBATT level is above or below Vbattldet = 1.9V (typical)

    Is this something you can use ?

  • Hi, thankyou for your supportive reply.

    If I understand this correctly, I can only check the instant VBATT level when VCC is supplied. What I was looking for is a flag that is set (independently of the presence of VCC), when VBATT temporarily drops during power off (VCC not supplied), e.g. because a battery is replaced during during periodic maintenance. As the device will be switched off, there is no chance that this can be detected by software.

    A temporary drop of VBATT can cause inconsistent/invalid content of RTC and/or Backup memory. I need to know of any inconsistencies when the device comes out of reset.

    Do I have to implement something in software?
    One idea would be to check if a "magic number", stored into Backup memory a previous session, is still correct. Would that be preferred solution?

  • If you are using the RTC, you can easily detect if has stopped when powered up by looking at the START bit in the RCR2 register.  If VBATT hasn't been lost and the RTC is supposed to be running, then START will still be set.  If it stopped, then START will be clear.

  • Thanks! That is what I'm looking for. Will try.