EmbeddedRelated.com
Forums

TimerA questions

Started by John Walker Ledbetter June 24, 2007
Hello everyone,

What I'm trying to do is to have TimerA generate an interrupt every
~1millisecond for timing purposes, based off of the 32768Hz Aux Clock.
It seems to work fine in a small test application that I've written, but
in a more complicated application, it always freezes after one interrupt
is generated. Basically, I'm hoping someone here can tell me if my
Timer code is sound or not, so I know where to focus my debugging
efforts :). Here's how I'm going about it (on the msp430x1611).

// initialize DCO , clear all LEDs, etc...
// ...
// no division for ACLK
BCSCTL1 &= ~(DIVA0 | DIVA1);

// initialize timerA:
TACTL = TACLR;
TACTL = TASSEL_ACLK | TAIE;

// reset timer value, clear our cc registers
TAR = 0;
TACCTL0 = TACCTL1 = TACCTL2 = 0;
TACCR1 = TACCR2 = 0;
// 32 ticks at 32768 Hz ~ 1millsecond
TACCR0 = 32;
// start timer
TACTL |= MC_UPTO_CCR0;

and then, the interrupt handler:

interrupt (TIMERA1_VECTOR) timera1_int()
{
// if the counter overflowed
if (TAIV & 10)
LED_TOGGLE(2);
}
I'd appreciate any help or criticism!
Thanks,

John

Beginning Microcontrollers with the MSP430

Hello,
i see some confusion in your code:
Timer 0 is a separate interrupt
Timer 1 has no relation with ccr0
ccr3????
i see you wish manage 1mSec, 1 Sec 10 Sec, so if timer run @1KHz all
is right otherwise you also need manage timer overflow in your Ta1 irq
service.
Best regards.
Roberto

--- In m..., "Martijn Broens" wrote:
>
> Good afternoon,
>
> Does anyone know if it's possible to use timer a multiple times with
> different intervals??
> I'd like to make a timerfunction that handles several functions for
> example
> I install a function that should occur every 10 sec one that comes every
> sec and one that comes every 1ms
>
> Question: is it possible to serve these ints like this:
> void TimerA_isr(void) __interrupt [TIMERA1_VECTOR]
> {
> switch (TAIV)
> {
> case 0x00: CCR0 += TIMER0PRESCALE;
> TimerIntFunc[TIMER0OVERFLOW_INT]; break;
> case 0x02: CCR1 += TIMER1PRESCALE;
> TimerIntFunc[TIMER1OVERFLOW_INT];break;
> case 0x04: CCR2 += TIMER2PRESCALE;
> TimerIntFunc[TIMER2OVERFLOW_INT];break;
> case 0x0A: CCR3 += TIMER3PRESCALE;
> TimerIntFunc[TIMER3OVERFLOW_INT];break;
> default: break;
> }
> }
>
> thanks Martijn.
>
>
>
Hi,
Ti say to set reset bit then release when all init done, just try change

TACTL = TACLR;
TACTL = TASSEL_ACLK | TAIE;
to
TACTL = TACLR;
TACTL = TASSEL_ACLK | TAIE | TACLR;

then simply add at end of init reset release
TACTL &= ~TACLR;

Regards
Roberto

--- In m..., John Walker Ledbetter
wrote:
>
> Hello everyone,
>
> What I'm trying to do is to have TimerA generate an interrupt every
> ~1millisecond for timing purposes, based off of the 32768Hz Aux Clock.
> It seems to work fine in a small test application that I've written,
but
> in a more complicated application, it always freezes after one
interrupt
> is generated. Basically, I'm hoping someone here can tell me if my
> Timer code is sound or not, so I know where to focus my debugging
> efforts :). Here's how I'm going about it (on the msp430x1611).
>
> // initialize DCO , clear all LEDs, etc...
> // ...
> // no division for ACLK
> BCSCTL1 &= ~(DIVA0 | DIVA1);
>
> // initialize timerA:
> TACTL = TACLR;
> TACTL = TASSEL_ACLK | TAIE;
>
> // reset timer value, clear our cc registers
> TAR = 0;
> TACCTL0 = TACCTL1 = TACCTL2 = 0;
> TACCR1 = TACCR2 = 0;
> // 32 ticks at 32768 Hz ~ 1millsecond
> TACCR0 = 32;
> // start timer
> TACTL |= MC_UPTO_CCR0;
>
> and then, the interrupt handler:
>
> interrupt (TIMERA1_VECTOR) timera1_int()
> {
> // if the counter overflowed
> if (TAIV & 10)
> LED_TOGGLE(2);
> }
> I'd appreciate any help or criticism!
> Thanks,
>
> John
>