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?