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.

Setting up the RTC in Tivaware 2.1 and TM4C1294NCPDT Launchpad

Edit: here is a link to another thread where I'm working on a much more useful example.   http://e2e.ti.com/support/microcontrollers/tiva_arm/f/908/p/369471/1300026.aspx#1300026

Hi,

I trying to use the Real Time Clock to count in seconds on a Nokia 5110. This the code: (includes are in a different file)

This code just displays a '1'. I read somewhere the RTC starts at 1. So, I can only conclude that timer0 isn't getting a clock source. 

How do I setup the clock source? I can't find a macro for XOSC0 (pin 66) or XOSC1  (pin 67), the 32 Khz oscillator on the launchpad.

I can't find a break down of how RTC works in Tivaware. Google isn't helping... Any help would be great.

Thanks,

Dan

  • Hi,

    The timer (Timer0 in your case) may be used as 32-bit RTC if using an external 32768Hz clock input. This clock input is internally divided up to 1 second and the 1 second count is added to the timer register. 

    In your case, you may think also to use the hibernation module RTC timer.

    Petrei

  • hey,

    How do I use the external 32 k clock input? I looked at all the timers and they all have ccp pins that do not go to pins 66 or 67 (pins on the micro controller that are hooked up to the 32 k osc)

    I'll look at the hibernation RTC module. 

    thanks,

    dan

  • Thanks Petrei. I got it to working with the hibernation module. To anyone that what to see a working example of the RTC:

    #include <stdint.h>
    #include <stdbool.h>
    #include <time.h>
    #include "inc/hw_hibernate.h"
    #include "inc/hw_memmap.h"
    #include "inc/hw_ssi.h"
    #include "inc/hw_types.h"
    #include "driverlib/gpio.h"
    #include "driverlib/hibernate.h"
    #include "driverlib/pin_map.h"
    #include "driverlib/ssi.h"
    #include "driverlib/sysctl.h"
    #include "Nokia5110.h"

    unsigned long now = 0;

    int main(void) {

    unsigned long ui32SysClock;

    ui32SysClock = SysCtlClockFreqSet((SYSCTL_XTAL_25MHZ | SYSCTL_OSC_MAIN |
    SYSCTL_USE_PLL | SYSCTL_CFG_VCO_480), 120000000);

    SysCtlPeripheralEnable(SYSCTL_PERIPH_HIBERNATE);

    HibernateEnableExpClk(ui32SysClock);
    HibernateClockConfig(HIBERNATE_OSC_LOWDRIVE);
    HibernateRTCEnable();

    Nokia5110_Init();
    Nokia5110_Clear();
    Nokia5110_OutString(" Time ");

    while(1){
    now = HibernateRTCGet(); //get the current value in seconds
    Nokia5110_SetCursor(4,2);
    Nokia5110_OutUDec(now);

    }
    }

    The nokia 5110 is just used to display some text and the current value in the RTC.

    Thanks,

    Dan

  • Hi,

    Can you mark this thread as answered?

    Petrei