This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

如何设置msp430中的定时器的频率,我想让定时器1/2/4/8hz启动?如下是我定时器的代码

BOOL xAD24PortTimersInit( uint8_t fs, uint8_t num)
{
BOOL bInitialized = FALSE;
ULONG ulReloadValue = ACLK;
// ULONG ulReloadValue = ( ACLK * ( ULONG )80 ) / (MB_TIMER_TICKS * 8UL);
/// ((ULONG)fs * 8UL)
sd24num = num;
if( ulReloadValue <= 1 )
{
ulReloadValue = 1;
}
else
{
ulReloadValue -= 1;
}

if( ulReloadValue < 0xFFFE )
{
/* Timer A clock source is ACLK, Start disabled. */
//TACTL = TASSEL0;TACTL |= TASSEL_0 + MC_2+TACLR;//外部引脚模式,,连续计数模式
TA1CTL = TASSEL_1 | ID_3 |MC_2; // SMCLK/8, Up Mode
// TACTL |= TASSEL_1 + MC_2 +ID_3;
TA1CCR0 = ( USHORT ) ulReloadValue;
/* Enable Timer A caputer compare interrupt. */
//TA1CCTL0 |= CCIE;
//TACCTL0 |= MC_2;
//__bis_SR_register(LPM0_bits | GIE); // Enter LPM0 w/ interrupts
//__no_operation(); // For debugger

bInitialized = TRUE;
}
return bInitialized;
}

void
vAD24PortTimersEnable( void )
{
/* Reset timer counter and set compare interrupt. */
TAR = 0;
TA1CCTL0 |= CCIE;
TA1CTL |= MC0;
sd24TimeOK = FALSE;


}

void
vAD24PortTimersDisable( void )
{
TA1CCTL0 &= ~CCIE;
TA1CTL &= ~( MC0 | MC1 );
sd24TimeOK = TRUE;
}


#if defined(__TI_COMPILER_VERSION__) || defined(__IAR_SYSTEMS_ICC__)
#pragma vector=TIMER1_A0_VECTOR
__interrupt void TA1_ISR(void)
#elif defined(__GNUC__)
void __attribute__ ((interrupt(TIMER1_A0_VECTOR))) TA1_ISR (void)
#else
#error Compiler not supported!
#endif
{
static unsigned char index = 0;
if(sd24OK == FALSE){
vPortsd24Start();
}
if(index >= sd24num || index>=SD24MAX) {
index = 0; // SET BREAKPOINT HERE
vAD24PortTimersDisable();
}


}