Home arrow Support arrow Forums

Luminary Micro Forums

Capper

Expert Boarder
Click here to see the profile of this user

2007/01/05 09:02

RTC on LM3S811 Eval Board

I can't get the RTC to work on Timer2, can someone give me a hint at what I'm doing wrong?

- I have a 32.768KHz signal on CCP4
- Pin configuration:

Code:

     GPIODirModeSet(GPIO_PORTC_BASEGPIO_PIN_7GPIO_DIR_MODE_HW);     GPIOPinTypeTimer(GPIO_PORTC_BASEGPIO_PIN_7);



- Timer configuration:
Code:

     TimerRTCDisable(TIMER2_BASE);     TimerConfigure(TIMER2_BASETIMER_CFG_32_RTC);     TimerLoadSet(TIMER2_BASETIMER_A0xFFFF);     TimerIntEnable(TIMER2_BASETIMER_RTC_MATCH);     TimerRTCEnable(TIMER2_BASE);     TimerEnable(TIMER2_BASETIMER_A);



- Startup.s
Code:

        DCD     IntDefaultHandler           Timer 0A         DCD     IntDefaultHandler           Timer 0B         DCD     IntDefaultHandler           Timer 1A         DCD     IntDefaultHandler           Timer 1B         EXTERN  Timer2AHandler         DCD     Timer2AHandler              Timer 2A         DCD     IntDefaultHandler           Timer 2B



- Timer interrupt handler:
Code:

 void Timer2AHandler(void) {     //     // Clear the timer interrupt.     //     TimerIntClear(TIMER2_BASETIMER_RTC_MATCH);     g_ulDistancePerSecond g_ulDistance; }



CAPPER

login or register to reply

LMI Dan

Moderator
Click here to see the profile of this user

2007/01/05 16:54

Re:RTC on LM3S811 Eval Board

Did you remember to enable the clocks to the GPIO and Timer modules in the Run-Mode Clock Gating Control registers (RCGCn) before you accessed them? This can be done using DriverLib with the following calls:

SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOB);
SysCtlPeripheralEnable(SYSCTL_PERIPH_TIMER2);

Also, I see that you call:

TimerLoadSet(TIMER2_BASE, TIMER_A, 0xFFFF);

Remember, RTC mode is the only mode in which the timer counts UP and not down. Typically, in RTC type applications, you would not adjust the load value (with TimerLoadSet). It is set to 1 when RTC mode is enabled and runs free. You set the match value based on the current value of the counter plus the period you would like to count to. In the interrupt handler, you can reset the match value to the next timeout period. This way the time is continuously running real-time and does not lose any time if you set the interval load register again.

login or register to reply

Capper

Expert Boarder
Click here to see the profile of this user

2007/01/05 20:50

Re:RTC on LM3S811 Eval Board

I did have this line:

SysCtlPeripheralEnable(SYSCTL_PERIPH_TIMER2);


I added this line:

SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOB);

I deleted this line:

TimerLoadSet(TIMER2_BASE, TIMER_A, 0xFFFF);

I added a line to turn on the USER_LED on entering the timer interrupt - the LED never turns on.

Hmmmmm....

Capper

login or register to reply

Capper

Expert Boarder
Click here to see the profile of this user

2007/01/05 21:21

Re:RTC on LM3S811 Eval Board

I checked the 32kHz clock signal by putting it on a port C pin I am using as a counter (also using an interrupt), and it counts (really fast!) and it looks nice and square (3.3vpp)on an oscilloscope.

If I change the port C int vector to point to the timer2 int code, it runs it and turns on the LED.

So....I don't think it's the hardware, or the interrupt code. Is there some other command that could be overriding the timer configuration?

I'll try re-writing the code to use timer0 or timer1 and see what happens.

Capper

Post edited by: Capper, at: 2007/01/05 21:42

login or register to reply

Capper

Expert Boarder
Click here to see the profile of this user

2007/01/06 12:05

Re:RTC on LM3S811 Eval Board

I figured out what I was missing:

Code:

     IntEnable(INT_TIMER2A);



Capper

login or register to reply