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.

MSP432E401Y: Correct time after resetting the microcontroller

Part Number: MSP432E401Y
Other Parts Discussed in Thread: MSP-EXP432E401Y

Hi all,

I am using time.h to get the current time, however when I press the reset button on my board, the time also resets and so it is effectively useless. Is there something I can do to work around this/ does anyone have any suggestions? 

Thanks,

Ryan

  • Hello Ryan

    You can use the hibernate module, configure the RTC and enable the RTC to be able to prevent this behavior. Right now we do not have the hibernate time TI driver, so you would need to use the driverlib in the RTOS framework to be able to do so.
  • Great, thank you.

    So after configuring the RTC and enabling it with the hibernate module, is there anything else I need to do to get the correct time after a reset? Or can I use time.h normally and it will work? Thanks.
  • Hello Ryan,

    The Hibernate module is not affected by the System Reset (unless you power down the board). Nothing else needs to be done. Your software needs to however read the Hibernate control register to make sure that RTC is already enabled so as to avoid a duplicate write to it.
  • Thanks Amit. I am attempting to do this, however for some reason after pressing the reset button, the function HibernateIsActive() returns false still, despite the fact that I configured and enabled it before I pressed reset. Is my code wrong for this purpose?

    void HibernateInit() {
        if(!HibernateIsActive()){
            HibernateClockConfig(HIBERNATE_OSC_LOWDRIVE);
            HibernateRTCEnable();
        }
    }

    Thanks for the help.

  • Hello Ryan,

    The clock is enabled by calling HibernateEnableExpClk API

    if(!MAP_HibernateIsActive())
    {
    MAP_HibernateEnableExpClk(systemClock);
    MAP_HibernateRTCSet(0);
    MAP_HibernateRTCEnable();
    }

    This is shown in the example in MSP432E4 SDK at the following path "C:\ti\simplelink_msp432e4_sdk_2_20_00_20\examples\nortos\MSP_EXP432E401Y\driverlib\hibernate_vdd3on_rtcwake"
  • Thanks Amit. Unfortunately I think I was a little misleading in my original post. I am using the time.h library and specifically the struct tm, which has values for year, mon, mday, etc. These are still unreliable after the rest.

    I have 2 questions about this:
    1. Are these functions only providing the correct date/time because the microcontroller is in debug mode and connected to my computer?
    2. If yes/no, how do I go about make sure that these functions will still work when I upload my code and then detatch it from my computer (which it has to power off for I believe).

    Thanks for the help.
  • Hello Ryan,

    Currently time.h uses the BIOS clock to calculate the time in the format specified. Moving it to the RTC would make it reset independent as the RTC in Hibernate works of the 32K crystal. Once the device is configured for VDD3ON mode on the LaunchPad, this will allow the device to work irrespective of the main CPU domain going in low power state.

    If the intent is to make the power supply disconnect keep the device's time working, the VDD3OFF mode needs to be used which requires a dedicated board design (not possible on the MSP-EXP432E401Y LaunchPad).

    Coming back to if we can repurpose the time.h to use RTC instead of the BIOS clock, let me check and confirm if in anyway that is possible with the current SDK.
  • Okay that's very good to know.
    Thanks for the info, and let me know what you find out.
  • Hello Ryam

    I have some update on the same. The following link is for the MSP432P4x device which is switched from timer to RTC. It would be applicable for the MSP432E4x as well (minus some of the nuances for MSP432P4x)

    processors.wiki.ti.com/.../TI-RTOS_MSP432_Timer

    Let me know if it helps.

**Attention** This is a public forum