芯片型号:MSP430F6779
我在TI官网下载的官方例程,在调试定时器时,发现对TA1CCR0初值发生改变时程序就无法运行。这里50000是官方的设置
但是当我改成10000时就无法实现LED闪烁。
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.
芯片型号:MSP430F6779
我在TI官网下载的官方例程,在调试定时器时,发现对TA1CCR0初值发生改变时程序就无法运行。这里50000是官方的设置
但是当我改成10000时就无法实现LED闪烁。
我的测试代码如下,可以闪烁
#include <msp430.h>
int main(void)
{
WDTCTL = WDTPW + WDTHOLD; // Stop WDT
P1DIR |= 0x01; // P1.0 output
TA1CCTL0 = CCIE; // CCR0 interrupt enabled
TA1CCR0 = 10000;
TA1CTL = TASSEL_2 + MC_2 + TACLR; // SMCLK, contmode, clear TAR
__bis_SR_register(LPM0_bits + GIE); // Enter LPM0, enable interrupts
__no_operation(); // For debugger
}
// Timer1 interrupt service routine
#if defined(__TI_COMPILER_VERSION__) || defined(__IAR_SYSTEMS_ICC__)
#pragma vector=TIMER1_A0_VECTOR
__interrupt void TIMER1_A0_ISR(void)
#elif defined(__GNUC__)
void __attribute__ ((interrupt(TIMER1_A0_VECTOR))) TIMER1_A0_ISR (void)
#else
#error Compiler not supported!
#endif
{
P1OUT ^= 0x01; // Toggle P1.0
//TA1CCR0 += 50000; // Add Offset to CCR0
}