EmbeddedRelated.com
Forums

TimerA questions

Started by Martijn Broens April 15, 2004
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.
 





Beginning Microcontrollers with the MSP430

Hi Martijn,

There's a few problems with that.

First, CCR0 and CCR1-CCRx are separate ISRs on Timer_A and Timer_B.

Secondly, to cover it with a 16 bit timer, you'd have to run it in
continuous
mode, and interrupt on match obviously.
Now, the ratio is 10,000 so there would be clock problem too.
Since you can only count to 65,535, the lowest value would have to be
say 4 in CCR for Timer A and then the highest CCR would be 40,000.
In this case you would need a 250 uS clock to Timer_A, have it interrupt
every 4 timer ticks for a 1 mS Int, every 4,000 ticks for a 1 sec Int, and
every 40,000 ticks for a 10 Sec Int.

Thirdly, you would have 3 Ints all queing each time you have the 10 sec Int.

Seems the timer_A would become quite inflexible.

Wouldn't it be easier to do a 1 mS tick, and then maintain a counter there,
and do func calls according to counter value ?

-- Kris

----- Original Message -----
From: "Martijn Broens" <martijn@mart...>
To: <msp430@msp4...>
Sent: Thursday, April 15, 2004 10:07 PM
Subject: [msp430] TimerA questions


> 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 Kris,
 
Yes it seems that the timer, at least the way i thought of using it,
becomes quite unuseble/un handy. I used to only have a clock timer on
timer a that would could msec's and then use a now() func that would
return the tick count. I think I'll keep it with that.
 
thanks Martijn.
  _____  

From: microbit [mailto:microbit@micr...] 
Sent: donderdag 15 april 2004 15:57
To: msp430@msp4...
Subject: Re: [msp430] TimerA questions
 
Hi Martijn,

There's a few problems with that.

First, CCR0 and CCR1-CCRx are separate ISRs on Timer_A and Timer_B.

Secondly, to cover it with a 16 bit timer, you'd have to run it in
continuous
mode, and interrupt on match obviously.
Now, the ratio is 10,000 so there would be clock problem too.
Since you can only count to 65,535, the lowest value would have to be
say 4 in CCR for Timer A and then the highest CCR would be 40,000.
In this case you would need a 250 uS clock to Timer_A, have it interrupt
every 4 timer ticks for a 1 mS Int, every 4,000 ticks for a 1 sec Int,
and
every 40,000 ticks for a 10 Sec Int.

Thirdly, you would have 3 Ints all queing each time you have the 10 sec
Int.

Seems the timer_A would become quite inflexible.

Wouldn't it be easier to do a 1 mS tick, and then maintain a counter
there,
and do func calls according to counter value ?

-- Kris

----- Original Message -----
From: "Martijn Broens" <martijn@mart...>
To: <msp430@msp4...>
Sent: Thursday, April 15, 2004 10:07 PM
Subject: [msp430] TimerA questions


> 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.
>
>
>
> 
>
>
>
> .
>
>
>
>
>
>

--
------
> > .