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.

TM4C123GH6PM: TM4C RTC Data recover on power reset using Vbat.

Part Number: TM4C123GH6PM

Hi,

I am using this TM4C123 controller where i need to keep running Hibernation RTC Module on Vbat, for RTC Time.

I have no idea how i will get time value when i power on controller after power reset,

I have connection for 3.3V cell on board.

Please help to provide answer for below questions:-

1.Code example for Hibernate  RTC Clock where time register keep updating only on Vbat supply.

2.Right now when i power off the controller my RTC Count stops,how can i be able to keep them running on Battery cell.

void HibernateISRHandler(void)
{
uint32_t ui32Status;

// Get the interrupt status and clear any pending interrupts.
ui32Status = HibernateIntStatus(true);
HibernateIntClear(ui32Status);

// Process the RTC match 0 interrupt.
if(ui32Status & HIBERNATE_INT_RTC_MATCH_0)
{
// update match value
uint32_t ui32RTCMatch;
ui32RTCMatch = HibernateRTCGet();
// calendar_read = HibernateRTCGet();
ulocaltime(ui32RTCMatch, &tm2);

HibernateDataGet(&ui32HibernateCount, 1);
ui32HibernateCount++;
if(ui32HibernateCount>=50000)
{
ui32HibernateCount=0;
}
HibernateDataSet(&ui32HibernateCount, 1);
HibernateRTCMatchSet(0,ui32RTCMatch + 1); // a second in the future

timer_tt++; // ### to disable
RTC_TIME_DETAILS.BIT_FIELD.SECOND = tm2.tm_sec;
RTC_TIME_DETAILS.BIT_FIELD.MINUTE = tm2.tm_min;
RTC_TIME_DETAILS.BIT_FIELD.HOUR = tm2.tm_hour;
RTC_TIME_DETAILS.BIT_FIELD.DAY = tm2.tm_mday;
RTC_TIME_DETAILS.BIT_FIELD.MONTH = tm2.tm_mon;
RTC_TIME_DETAILS.BIT_FIELD.YEAR = tm2.tm_year;


}

}

using Above code i am not able to recover value of rtc clock,

I am new to rtc clock of this controller so some working example of RTC Clock count  during main power of controller is off and only VBAT is connected.

Thanks,

  • The RTC continues to update the seconds (and sub-seconds) counters when running off of VBAT.  The 32 bit seconds counter will overflow after 138 years.  Here is a simple program that prints the number of elapsed seconds using UART0. The RTC counter continues to increment if the Hibernate module is supplied with a 3.3V battery.

    //*****************************************************************************
    //
    // Copyright (c) 2012-2018 Texas Instruments Incorporated.  All rights reserved.
    // Software License Agreement
    // 
    // Texas Instruments (TI) is supplying this software for use solely and
    // exclusively on TI's microcontroller products. The software is owned by
    // TI and/or its suppliers, and is protected under applicable copyright
    // laws. You may not combine this software with "viral" open-source
    // software in order to form a larger program.
    // 
    // THIS SOFTWARE IS PROVIDED "AS IS" AND WITH ALL FAULTS.
    // NO WARRANTIES, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT
    // NOT LIMITED TO, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
    // A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. TI SHALL NOT, UNDER ANY
    // CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL, OR CONSEQUENTIAL
    // DAMAGES, FOR ANY REASON WHATSOEVER.
    // 
    //*****************************************************************************
    
    #include <stdint.h>
    #include <stdbool.h>
    #include <time.h>
    #include "inc/hw_types.h"
    #include "inc/hw_memmap.h"
    #include "driverlib/pin_map.h"
    #include "driverlib/rom.h"
    #include "driverlib/rom_map.h"
    #include "driverlib/sysctl.h"
    #include "driverlib/gpio.h"
    #include "driverlib/uart.h"
    #include "driverlib/hibernate.h"
    #include "utils/uartstdio.h"
    
    uint32_t g_ui32SysClock;
    
    
    //*****************************************************************************
    //
    // Configure the UART and its pins.  This must be called before UARTprintf().
    //
    //*****************************************************************************
    void
    ConfigureUART(void)
    {
        //
        // Enable the GPIO Peripheral used by the UART.
        //
        ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA);
    
        //
        // Enable UART0
        //
        ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_UART0);
    
        //
        // Configure GPIO Pins for UART mode.
        //
        ROM_GPIOPinConfigure(GPIO_PA0_U0RX);
        ROM_GPIOPinConfigure(GPIO_PA1_U0TX);
        ROM_GPIOPinTypeUART(GPIO_PORTA_BASE, GPIO_PIN_0 | GPIO_PIN_1);
    
        //
        // Use the internal 16MHz oscillator as the UART clock source.
        //
        UARTClockSourceSet(UART0_BASE, UART_CLOCK_PIOSC);
    
        //
        // Initialize the UART for console I/O.
        //
        UARTStdioConfig(0, 115200, 16000000);
    }
    void ConfigureRTC(void)
    {
        //
        // Need to enable the hibernation peripheral after wake/reset, before using
        // it.
        //
        SysCtlPeripheralEnable(SYSCTL_PERIPH_HIBERNATE);
        //
        // Wait for the Hibernate module to be ready.
        //
        while(!SysCtlPeripheralReady(SYSCTL_PERIPH_HIBERNATE))
        {
        }
        //
        // Enable clocking to the Hibernation module.
        //
        HibernateEnableExpClk(g_ui32SysClock);
        //
        // User-implemented delay here to allow crystal to power up and stabilize.
        //
        //
        // Configure the clock source for Hibernation module and enable the RTC
        // feature.
        //
        HibernateClockConfig(HIBERNATE_OSC_LOWDRIVE);
        HibernateRTCEnable();
    }
    
    //*****************************************************************************
    //
    // Main 'C' Language entry point.  
    //
    //*****************************************************************************
    int
    main(void)
    {
    
        uint32_t seconds;
        //
        // Setup the system clock to run at 80 MHz from PLL with crystal reference
        //
        SysCtlClockSet(SYSCTL_SYSDIV_4|SYSCTL_USE_PLL|SYSCTL_XTAL_16MHZ|
                        SYSCTL_OSC_MAIN);
        g_ui32SysClock = SysCtlClockGet();
    
        ConfigureUART();
        UARTprintf("Elapsed Seconds!\n");
        UARTprintf("Press 'ESC' to reset the timer\n");
        ConfigureRTC();
    
        //
        // Loop Forever
        //
        while(1)
        {
            //
            // Delay for a bit
            //
            SysCtlDelay(g_ui32SysClock/8);
            seconds = HibernateRTCGet();
            UARTprintf("\r%d            ", seconds);
            if(UARTCharGetNonBlocking(UART0_BASE) == 27)
            {
                HibernateRTCSet(0);
            }
    
        }
    }
    

  • Thanks Bob,

    I got it working.