Other Parts Discussed in Thread: MSP430F2274
Hi! I'm using EZ430-RF2500 board. All works fine excepting timer.
I thought problem is in my code, or my project. So, i tried to load the code from TI examples, and it didn't work too.
If i run timer from ACLK (TBSSEL_1), value of TBR does not change. If timer's clock source is SMCLK, TBR changes, but interrupt does not occur.
I tried to work with timer A or timer B, tried to change workbench from IAR to Code Composer Studio, tried to connect another MSP430F2274 - where is no changes.
I really don't understand what's the problem: USART works, ADC works...
Here is my code, but it's a copy from TI examples.
#include "msp430x22x4.h"
void main(void)
{
WDTCTL = WDTPW + WDTHOLD; // Stop WDT
P4SEL |= 0x07; // P4.x - P4.2 option select
P4DIR |= 0x07; // P4.x = outputs
P1DIR |= 0x001; // P1.0 = output
TBCCTL0 = OUTMOD_4 + CCIE; // TBCCR0 interrupt enabled
TBCCTL1 = OUTMOD_4 + CCIE; // TBCCR1 interrupt enabled
TBCCTL2 = OUTMOD_4 + CCIE; // TBCCR2 interrupt enabled
TBCTL = TBSSEL_2 + MC_2 + TBIE; // ACLK, contmode, interrupt
TBCCR0 = 20;
__bis_SR_register(LPM3_bits + GIE); // Enter LPM3, interrupts enabled
}
// ISR for TBCCR0
#pragma vector=TIMERB0_VECTOR
__interrupt void TB0_ISR(void)
{
TBCCR0 += 4; // Offset until next interrupt
}
// Common ISR for TBCCR1-2 and overflow
#pragma vector=TIMERB1_VECTOR
__interrupt void TBX_ISR(void)
{
switch (TBIV) // Efficient switch-implementation
{
case 2: // TBCCR1
TBCCR1 += 8; // Offset until next interrupt
break;
case 4: // TBCCR2
TBCCR2 += 16; // Offset until next interrupt
break;
case 14: // Overflow
P1OUT ^= 0x01; // Toggle P1.0
break;
}
}