This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

TM4C129ENCPDT: HibernateEnableExpClk() hangs without XOSC input

Part Number: TM4C129ENCPDT

While researching the Hibernate module, Tamper module, and Real Time Clock, I discovered that the Hibernate module cannot be enabled without some sort of clock source on the XOSC0 pin.

The symptom is that _HibernateWriteComplete() locks up, waiting for HIB_CTL_WRC to be set, but that never occurs.

Note that I've been able to confirm that the Tamper module can detect failure of a crystal-based RTC source, but it doens't seem possible to detect failure during a cold boot. It would seem that some additional setup is needed before calling HibernateEnableExpClk(), besides the obvious SysCtlPeripheralEnable(SYSCTL_PERIPH_HIBERNATE) and SysCtlPeripherReady(SYSCTL_PERIPH_HIBERNATE) wait.

Also, I tried rewriting _HibernateWriteComplete() to allow a 1.5-second (1500 ms) timeout, after which SysCtlPeripheralReset(SYSCTL_PERIPH_HIBERNATE) is called before repeating the Enable() and Ready() calls again. The peripheral reset, inspired by HIB#19, does not seem to help in the case where there is no crystal or other clock input on XOSC0.

  • Hi Brian,

    Brian Willoughby18 said:
    I discovered that the Hibernate module cannot be enabled without some sort of clock source on the XOSC0 pin.

      The hibernation module is enabled by setting the CLK32EN high. Except the HIBIO register and a portion of the HIBIC registers, all other registers (HIBCTL register where CLK32EN resides) in the Hibernation module are clocked by the RTC clock(external 32kHz crystal or internal LFIOSC)  Sort of catch-22, if there is not a clock provided to the Hibernation module in the first place then there is no possibility to write to the CLK32EN bit  to enable the Hibernation module. 

    Excerpt from the datasheet as follows:

    In addition, the CLK32EN bit in the HIBCTL register must be set before accessing
    any other Hibernation module register.
    Note: Except for the HIBIO and a portion of the HIBIC register, all other Hibernation module
    registers are on the Hibernation module clock domain and have special timing requirements.
    Software should make use of the WRC bit in the HIBCTL register to ensure that the required
    timing gap has elapsed. If the WRC bit is clear, any attempted write access is ignored. See
    “Register Access Timing” on page 535. The HIBIO register and bits RSTWK, PADIOWK and
    WC of the HIBIC register do not require waiting for write to complete. Because these registers
    are clocked by the system clock, writes to these registers/bits are immediate.

    Writing to registers other than the HIBCTL and HIBIM before the CLK32EN bit in the HIBCTL
    register has been set may produce unexpected results.

    The Hibernation module is enabled by setting the CLK32EN bit of the HIBCTL register. The CLK32EN
    bit must be set before accessing any other Hibernation module register. The type of clock source
    used for the HIB module is selected by setting the OSCSEL and OSCBYP bit of the HIBCTL register.
    If the internal low frequency precision oscillator is used as the clock source, the OSCSEL bit should
    be set to a 1 at the same time the CLK32EN bit is set. If a crystal is used for the clock source, the
    software must leave a delay of tHIBOSC_START after writing to the CLK32EN bit and before any other
    accesses to the Hibernation module registers. The delay allows the crystal to power up and stabilize.
    If an external oscillator is used for the clock source, no delay is needed. When using an external
    clock source, the OSCBYP bit in the HIBCTL register should be set.

    Brian Willoughby18 said:
    Note that I've been able to confirm that the Tamper module can detect failure of a crystal-based RTC source, but it doens't seem possible to detect failure during a cold boot. It would seem that some additional setup is needed before calling HibernateEnableExpClk(), besides the obvious SysCtlPeripheralEnable(SYSCTL_PERIPH_HIBERNATE) and SysCtlPeripherReady(SYSCTL_PERIPH_HIBERNATE) wait.

    Glad that you are able to confirm the tamper module is detecting the failure. This is at least good during runtime. For cold start, I'm unable to offer solution for you. You need to have an operating RTC clock  before you can enable and set up the Hibernation module (.e.g. enabling the tamper module for XOSC failure detection). But if the RTC clock is bad to begin with, you cannot detect itself. It's a catch-22 scenario again. What is needed is XOSC failure detection without the need to first enable the Hibernation module. Looks like what it is today, it is not achievable. 

      What is your Watchdog timeout period? Is it possible to start the watchdog using other clock as clock source? Before the first watchdog timeout, you perform the XOSC detection. If there is no failure, you will switch the watchdog to the XOSC source.

  • Thank you for the clarification.

    I have designed several products around the TM4C129x family.

    For those that have no 32,768 Hz crystal, it sounds like it should be sufficient to enable the LFIOSC at the same time as the CLK32EN bit. If any of the Hibernate module features are needed, but there isn't an RTC, then there would at least be a way to enable the Hibernate module.

    For products that do have a 32,768 Hz crystal or clock source, there doesn't seem to be a simple way to detect a failure at startup. If absolutely necessary, a redundant firmware subsystem could use MOSC or PIOSC to detect a non-functional RTCOSC before starting the Hibernate module. After the Hibernate module is started, RTCOSC failure can be automatically detected. Perhaps after the SysCtlPeripheralReset(), the code could set OSCSEL and OSCBYP during the retry attempt.

    Another option is to simply assume that a working crystal is highly unlikely to fail. All of our products are tested before leaving manufacturing. Speaking with other team members, I'm told that voltage regulators and other critical elements of the circuit are far more likely than a crystal to fail in the field. In this case, I'm likely to just allow the infinite loop in ROM for HibernateEnableExpClk() to be used without a fallback. If boards hang up in the field, then they'll just have to be repaired or replaced.