中断的使用是否一定要进入LPM模式?
使用TI范例TA来做修改
int ta=0;
int main(void)
{
WDTCTL = WDTPW + WDTHOLD; // Stop WDT
P1DIR |= 0x01; // P1.0 output
CCTL0 = CCIE; // CCR0 interrupt enabled
CCR0 = 50000;
TACTL = TASSEL_2 + MC_1; // SMCLK, upmode
// _BIS_SR(LPM0_bits + GIE); // Enter LPM0 w/ interrupt
if(ta == 10)
{
P1OUT ^= 0x01; // Toggle P1.0
ta = 0;
}
}
// Timer A0 interrupt service routine
#pragma vector=TIMER0_A0_VECTOR
__interrupt void Timer_A (void)
{
ta = ta+1;
}
(1)运行时发现TA动作,但没有进入中断
加入_BIS_SR(LPM0_bits + GIE); // Enter LPM0 w/ interrupt
(2)如进入LPM模式,则进入中断 ta 增加
但ta会远大于10,无法进入if回圈
求指教,谢谢
此帖出自
小平头技术问答
- int ta=0;
- int main(void)
- {
- WDTCTL = WDTPW + WDTHOLD; // Stop WDT
- P1DIR |= 0x01; // P1.0 output
- CCTL0 = CCIE; // CCR0 interrupt enabled
- CCR0 = 50000;
- TACTL = TASSEL_2 + MC_1; // SMCLK, upmode
- _BIS_SR(LPM0_bits + GIE); // Enter LPM0 w/ interrupt
- while(1)
- {
- if(ta == 10)
- {
- P1OUT ^= 0x01; // Toggle P1.0
- ta = 0;
- }
- }
- }
- // Timer A0 interrupt service routine
- #pragma vector=TIMER0_A0_VECTOR
- __interrupt void Timer_A (void)
- {
- ta = ta+1;
- LPM0;
- }
复制代码一周热门 更多>