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.

Hibernate-modul as an RTC-modul is not working correctly

Other Parts Discussed in Thread: TM4C123GH6PM

I have written a program on the microcontroller tm4c123GH6PM  that is  working as a second counter counting the seconds since I run the program.  The counter must give me the number of seconds and subseconds ( Resolution: 1/32768). I have already read some useful informations on the datasheet. I knew that I should use an external crystal to clock the hibernate-Modul. Clocking the Hibernate-modul is independent from the main system clock. That´s why I used the external crystal SYSCTL_OSC_EXT32. The counter worked but it does not count from 0. It starts to counter from a value different from 0, although I power off /on the board. Here is some code:
    int main(void){

SysCtlClockSet(SYSCTL_OSC_MAIN);
SysCtlPeripheralEnable(SYSCTL_PERIPH_HIBERNATE);
HibernateEnableExpClk(SYSCTL_OSC_EXT32);
HibernateClockConfig(HIBERNATE_OSC_HIGHDRIVE);
HibernateRTCEnable();
while(1){
printf("--RTC_count in s: %d, subsecond: %d s\n",HibernateRTCGet(),HibernateRTCSSGet());
SysCtlDelay(3000);
}

}

Here is an example of an output:

--RTC_count in s: 9, subsecond: 0.421112 s
--RTC_count in s: 9, subsecond: 0.521515 s
--RTC_count in s: 9, subsecond: 0.692902 s
--RTC_count in s: 9, subsecond: 0.752075 s
--RTC_count in s: 9, subsecond: 0.832336 s
--RTC_count in s: 9, subsecond: 0.903046 s

I am asking, if there is a function that resets the counter. I don´t know why it cannot count from zero. Any Idea?

  • Hello Jo

    You would need to reload the Hibernate RTC by first disabling the RTC using HibernateRTCDisable, then loading the count using HibernateRTCSet and finally enabling the RTC using HibernateRTCEnable

    Regards
    Amit
  • Hallo Amit,

    thank you for your answer. It works now.The counter for seconds starts from zero but the counter for subseconds starts from a very small value. Here is the example of an output.

    Start in s: 0, Start in subseconds: 6
    --RTC_count in s: 0, subsecond: 0.135925 s

    Since I am writing an application for a hard realtime system, I cannot allow to my subseconds counter to start from a value different from 0.  I looked for a method in driverlib that sets the subseconds to 0 but I find nothing. Any Suggetions?

     

  • Hello Jo

    The write to HIBRTCLD register will clear the HIBRTCSS register. So may be the value being read is due to some delay. Also when reading the register note that they have to be synchronized across clock domains, so a delay would always come in.

    Regards
    Amit