Hello all,
I'am using my own TM4C123GH6PM Custom Board and I'am trying to implement the RTC of the MCU.
I'am using the 32.768 KHz crystal and connected a 3V Coin cell to the Vbat pin with an RC circuit(51 ohm & 0.1 uF) between VBat and Coin cell.
The code below is written for RTC
time_t calendar_write;
time_t calendar_read;
struct tm tm1 = {0,15,16,2,3,2018-1900,1,0,0};
struct tm tm2 = {0};
int main()
{
SysCtlClockSet(SYSCTL_SYSDIV_2_5 | SYSCTL_USE_PLL | SYSCTL_OSC_MAIN | SYSCTL_XTAL_16MHZ); // clock at 80 Mhz
ui32SysClkFreq = 80000000;
// Enable the Hibernation module.
SysCtlPeripheralEnable(SYSCTL_PERIPH_HIBERNATE);
// Wait for the Hibernate module to be ready.
while(!SysCtlPeripheralReady(SYSCTL_PERIPH_HIBERNATE))
{
}
HibernateEnableExpClk(ui32SysClkFreq);
//
// Wait an amount of time for the module to power up.
//
// Configure the clock source for Hibernation module and enable the
// RTC feature.
HibernateClockConfig(HIBERNATE_OSC_HIGHDRIVE);
HibernateRTCEnable();
HibernateCounterMode(HIBERNATE_COUNTER_RTC);
calendar_write = umktime(&tm1);
HibernateRTCSet(calendar_write);
while(1)
{
calendar_read = HibernateRTCGet();
ulocaltime(calendar_read, &tm2);
// format the output for uart
strftime((char *)buf_rz, 32, "%c\r\n", &tm2);
}
}
The issue is that I'am not able to restore the hour:minutes:seconds values after power cycle. The RTC resets when I power cycle the board.