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.

Getting RTC (Real Time Clock) counter to work on EKS-LM4F232 Eval Board

I have the stock Stellaris Eval Kit EKS-LM4F232 and am trying to get the RTC counter to work.  My code is:

    SysCtlPeripheralEnable(SYSCTL_PERIPH_TIMER1);
    SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOB);
    GPIOPinConfigure(GPIO_PB4_T1CCP0);
    GPIOPinTypeTimer(GPIO_PORTB_BASE, GPIO_PIN_4);
    TimerConfigure(TIMER1_BASE, TIMER_CFG_32_RTC);
    TimerRTCEnable(TIMER1_BASE);
    TimerEnable(TIMER1_BASE, TIMER_A);
    TimerLoadSet(TIMER1_BASE, TIMER_A, 45);

    while(1)
    {
        delay_ms(1000);
        diag_printf("RTC Count: %d\n", TimerValueGet(TIMER1_BASE, TIMER_A) );
    }

I've looked at some other processor examples and the data sheet and have been trying to piece it together.  I Load it with a value of 45 and do see the 45 but it never changes.  I want it to use the 32KHz crystal that comes on the board.

Thanks,

Bill

  • dear Bill

    I have met the same issue:( Have you make it work? What's the root cause?

  • Hi Bill,

         Am not sure, but try using TimerLoadSet before TimerEnable.

    -kel

  • No I don't have it working yet.  I'm waiting for someone to post a suggestion for me to try

    Best,

    Bill

  • Thanks - However, I tried that and still did not work.

    Best,

    Bill

  • Hi Bill,

    How are you using the 32 kHz crystal on the board? Because it is a crystal and not an oscillator, you have to connect it to an oscillator to get a signal that would be usable by the GPIO.

    Looking at your code, you should use the TIMER_CFG_RTC parameter for your TimerConfigure() function.

    Regards,

    Sue

  • Thanks Sue.  I tried that but it still does not work. 

    Looking at the eval board schematics,  the 32KHZ Crystal is connected to pins 76 and 74 which are XOSC1 and XOSC0 respectively.   So somehow I need route one of these pins to the timer?  Basically I need an accurate clock (1 Second rate) and I saw the Chip docs that this can be done using the external 32KHz crystal.  However, I can't seem to get the configuration correct with the IO pins and timers.  I checked for any example code in the Stellaris libraries but did not see any. 

    Best,

    Bill

  • Hi Bill,

    That's what I am trying to explain.  A crystal has to be connected to an oscillator in order to provide a usable signal to the system clock or the timer CCP input.  The 32.768 kHz crystal that is on the board is a crystal and when you connect it to pins XOSC1 and XOSC0, you connect it to an oscillator that is inside the MCU which produces the usable clock signal.  You cannot directly connect the output of the crystal to the CCP pin and expect it to work.  Does that make sense?

    Regards,

    Sue

  • Thanks Sue.  I probably misled you above.  When I stated "route one of these pins"  I meant through the system configuration using the software functions (i.e. TimerConfigure(), TimerEnable(), etc...)  That is I have a stock eval board and am just using the stellaris software functions to see if I can get the RTC timer going.

    So let me describe our end goal - We would like to use both the external crystal to run a precise real-time counter (the 1 second interval) and the other external crystal (Y2 - 16MHz) to run the processor.  Right now I have the system clock configured as (Using the 16MHz crystal):


    ROM_SysCtlClockSet(SYSCTL_SYSDIV_4 | SYSCTL_USE_PLL | SYSCTL_XTAL_16MHZ | SYSCTL_OSC_MAIN);

    So that I am using this clock (based on 16MHz Crystal) to run the processor.

    So then maybe you are stating that I can't use the 32KHz to run a RTC as the system would then have to run off of the 32KHz crystal and not the 16MHz.

    Thanks,

    Bill

  • Hi Bill,

    In order to use the general-purpose timer in RTC mode, you have to provide a 32.768 kHz signal on the associated GPIO pin.  You cannot do that with the existing components on the EK-LM4F232 board.

    Regards,

    Sue

  • hi friend,

    maybe is  TimerConfigure(TIMER1_BASE, TIMER_CFG_RTC);

    how in the guide user's

  • I'm trying the same thing as an RTC clock but either only goes to 5 minutes, or just be seen in the hyperterminal 1