Jump to content
43oh

How to add second Timer ?


Recommended Posts

Hi huys,

I am currently using only TimerA in my code and here is code of use:

 

//choosing clk down below

BCSCTL1 |= XTS;

do
{ 
  IFG1 &= ~OFIFG; 
  for (i = 0xFF; i > 0; i--); 
} while ((IFG1 & OFIFG) == OFIFG); 

BCSCTL1 |= DIVA_1; 
BCSCTL2 |= SELM0 | SELM1; 

// setting-up timerA for 500khz and interruption each 100ms 
TACTL = TASSEL_1 + MC_1 +ID_3; 
CCR0=50000; 
_EINT(); 
for (;
{ 
_BIS_SR(LPM3_bits); 
// service of interrupts here 
}

#pragma vector=TIMERA0_VECTOR 
__interrupt void Timer_A (void){ 
_BIC_SR_IRQ(LPM3_bits); 
// doing things each 100ms
}

 

I need to use also TimerB, so how to add it using same clock or different ?

 

I am asking becouse i dont know what registers to set up to avoid conflict of variables.

 

How to do add other TimerB using same clock as TimerA or different ?

Link to post
Share on other sites

Be careful. Most MSP devices only contain 1 base timer module. Within that 1 timer module there may be several CCM's (Capture/compare modules) each CCM can cause an interrupt when the TAR (timer value) matches the CCR (Capture compare register)

 

If you tell us what IC you are using I can clarify more, but if your device has got a timerB module you should be able to set it up identically to your timerA module just replace the A's with B's

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...