EmbeddedRelated.com
Forums

interrupt intervals with the timerB latch register

Started by balucharly January 17, 2006
Hi there,

I'm new with MSP430

I try to get a function running that is automatically called every 
1ms by an interrupt of the timerB.

In the TI Userguide for the MSP430x1xx Family, on page 238 picture 12-
6 is an example that the MSP loads the interval by hardware.

But I dont know how to do this

here is a sample of my code: (using Crossworks)

// SCLK = 32768

// initialize Timer B
TBCTL = CNTL1 + TBSSEL0 + MC1 + SET + TBIE + TBIFG; 
TBCCTL1 = CCIS1 + SCS + CLLD1 + CLLD0 + OUTMOD2 + OUTMOD0 + CCIE;

// capture/compare value 1
TBCCR1  = 33; // 33/SCLK = 1.0071ms

static void timerISRB1(void) __interrupt[TIMERB1_VECTOR]
{
  const uint16 timer_ivr = TBIV; // store interrupt vector 

  if (timer_ivr == TBCCR1_CCIFG) 
  {
    // do something every interrupt
  }
}

I set CLLD to 11 this means "TBCLx loads when TBR counts to TBCLx"
but this does not work.

I get an Interrupt every 2s (2^16/SCLK) but this is not what I need.

Thanks for your help

with kind regards

Markus







Beginning Microcontrollers with the MSP430

I suggest that you use the up mode, Markus. It's simpler and I think is 
better in your case. In this case you have to use TBCCR0 to set the 
period. Note that you have enabled 2 interrupts, TBIE and CCIE, enable 
just one of them. Your configuration of CLLD bits is incorrect, 
according to the timer mode you're currently using. Check the note in 
parenthesis in the description of the TBCCTLx register. You could try to 
get a sample code in the MSP430 site, there should be one similar to 
what you need.

Regards,
Adriano.


balucharly wrote:
> Hi there,
> 
> I'm new with MSP430
> 
> I try to get a function running that is automatically called every 
> 1ms by an interrupt of the timerB.
> 
> In the TI Userguide for the MSP430x1xx Family, on page 238 picture 12-
> 6 is an example that the MSP loads the interval by hardware.
> 
> But I dont know how to do this
> 
> here is a sample of my code: (using Crossworks)
> 
> // SCLK = 32768
> 
> // initialize Timer B
> TBCTL = CNTL1 + TBSSEL0 + MC1 + SET + TBIE + TBIFG; 
> TBCCTL1 = CCIS1 + SCS + CLLD1 + CLLD0 + OUTMOD2 + OUTMOD0 + CCIE;
> 
> // capture/compare value 1
> TBCCR1  = 33; // 33/SCLK = 1.0071ms
> 
> static void timerISRB1(void) __interrupt[TIMERB1_VECTOR]
> {
>   const uint16 timer_ivr = TBIV; // store interrupt vector 
> 
>   if (timer_ivr == TBCCR1_CCIFG) 
>   {
>     // do something every interrupt
>   }
> }
> 
> I set CLLD to 11 this means "TBCLx loads when TBR counts to
TBCLx"
> but this does not work.
> 
> I get an Interrupt every 2s (2^16/SCLK) but this is not what I need.
> 
> Thanks for your help
> 
> with kind regards
> 
> Markus
> 
> 
> 
> 
> 
> 
> 
> 
> .
> 
>  
> Yahoo! Groups Links
> 
> 
> 
>  
> 
>