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.

TM4C129XNCZAD: I want to implement RTC in tn4c129XNCZAD

Part Number: TM4C129XNCZAD
Other Parts Discussed in Thread: EK-TM4C1294XL

Tool/software:

Hello,

We are using TM4C129XNCZADI3R  part number . I  need RTC parameter. I have tivaware latest package 295 but not able to find out rtc.h file .

Does it have inbuilt RTC?

void Hibernate_RTC_Init(void)
{

// Enable the Hibernation module
SysCtlPeripheralEnable(SYSCTL_PERIPH_HIBERNATE);
while(!SysCtlPeripheralReady(SYSCTL_PERIPH_HIBERNATE));

// Enable access to the hibernate module
HibernateEnableExpClk(SysCtlClockGet());

// Enable the RTC and the clocking from external oscillator
HibernateClockConfig(HIBERNATE_OSC_LOWDRIVE);

// Wait for the oscillator to stabilize
SysCtlDelay(SysCtlClockGet() / 3); // ~1 second delay

// Enable RTC mode
HibernateRTCEnable();

// If you want to reset the counter
HibernateRTCSet(0);

}

//*************************************************************************************************

// Set RTC to specific timestamp (e.g., Unix time)
void SetRTCTime(uint32_t timestamp) {
HibernateRTCSet(timestamp);
}

// Read current time
uint32_t GetRTCTime(void) {
return HibernateRTCGet();
}

 

current_time= GetRTCTime();

It gives  always 0 . Is any other thing require to do?

Crystal properly connected and checked on oscilloscope

  • Hi,

      I will reply to you later today as I'm currently on vacation. The RTC is part of the Hibernate module. Please reference the Hibernate example on how to setup the RTC counter.

  • Hi,

      Have you been able to reference the hibernate example in C:\ti\TivaWare_C_Series-2.2.0.295\examples\boards\ek-tm4c1294xl\hibernate or C:\ti\TivaWare_C_Series-2.2.0.295\examples\boards\ek-tm4c1294xl\hibernate_calendar. These two examples use RTC to wake up from hibernate mode. Below are the snippet of code to setup RTC for wakeup in five seconds. 

    int
    main(void)
    {
        uint32_t ui32Status;
    
        //
        // Run from the PLL at 120 MHz.
        // Note: SYSCTL_CFG_VCO_240 is a new setting provided in TivaWare 2.2.x and
        // later to better reflect the actual VCO speed due to SYSCTL#22.
        //
        g_ui32SysClock = MAP_SysCtlClockFreqSet((SYSCTL_XTAL_25MHZ |
                                                 SYSCTL_OSC_MAIN |
                                                 SYSCTL_USE_PLL |
                                                 SYSCTL_CFG_VCO_240), 120000000);
    
        //
        // Enable the hibernate module.
        //
        MAP_SysCtlPeripheralEnable(SYSCTL_PERIPH_HIBERNATE);
    
        //
        // Read and clear any status bits that might have been set since
        // last clearing them.
        //
        if(MAP_HibernateIsActive())
        {
            //
            // Read the status bits to see what caused the wake.
            //
            ui32Status = MAP_HibernateIntStatus(0);
            MAP_HibernateIntClear(ui32Status);
        }
    
        //
        // Set up the serial console to use for displaying messages.
        //
        ConfigureUART();
        UARTprintf("Hibernation with RTC Wake Example.\n");
    
        //
        // Enable the GPIO peripheral for on-board LEDs.
        //
        MAP_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPION);
    
        //
        // Configure the GPIOs for LEDs D1 and D2.
        //
        MAP_GPIOPinTypeGPIOOutput(GPIO_PORTN_BASE, GPIO_PIN_1 | GPIO_PIN_0);
    
        //
        // Enable the Hibernation module for operation.
        //
        MAP_HibernateEnableExpClk(0);
    
        //
        // Wait for 32.768kHz clock to stabilize.
        //
        while(!(HWREG(HIB_RIS) & HIB_RIS_WC));
    
        //
        // Configure the drive strength for the crystal.
        //
        MAP_HibernateClockConfig(HIBERNATE_OSC_LOWDRIVE);
    
        //
        // Enable the Hibernate module RTC mode.
        //
        MAP_HibernateRTCEnable();
    
        //
        // Load initial RTC value.
        //
        MAP_HibernateRTCSet(0);
    
        //
        // Set initial match value to trigger RTC after 5 seconds.
        //
        MAP_HibernateRTCMatchSet(0, 5);
    
        //
        // Enable RTC match interrupt.
        //
        MAP_HibernateIntEnable(HIBERNATE_INT_RTC_MATCH_0);
    
        //
        // Configure MCU interrupts.
        //
        MAP_IntEnable(INT_HIBERNATE_TM4C129);
    
        //
        // Enable MCU interrupts.
        //
        MAP_IntMasterEnable();
    
        //
        // Turn on LED D1.
        //
        MAP_GPIOPinWrite(GPIO_PORTN_BASE, GPIO_PIN_1, GPIO_PIN_1);
    
        //
        // Enter Hibernation Mode.
        //
        UARTprintf("Entering Hiberation, waking in 5 seconds.\n");
        MAP_HibernateRequest();
    
        while(1)
        {
            //
            // Do nothing, Hibernate interrupt routine will handle the rest.
            //
        }
    }