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.

请问 msp430f5310 的 Timer overflow 中断源来自哪里

Other Parts Discussed in Thread: MSP430F5310

我们使用的是 msp430f5310, 测试代码如下:

#include <msp430f5310.h>

#pragma vector=TIMER0_A0_VECTOR
__interrupt void timer0_A0_ISR(void)
{
    TA0CTL &= ~TAIFG;
}

#pragma vector=TIMER0_A1_VECTOR

__interrupt void timer0_A1_ISR(void)

{

switch(__even_in_range(TA0IV, 14))
{
case 0:
break; // No interrupt
case 2:
break;
case 4:
break;
case 6:
break;
case 8:
break;
case 14: // overflow
break;
default:
break;
}

}


void main(void)
{
WDTCTL = WDTPW + WDTHOLD; // Stop watchdog timer
P5SEL |= BIT4+BIT5; // Select XT1

UCSCTL6 &= ~(XT1OFF); // XT1 On
UCSCTL6 |= XCAP_3; // Internal load cap
UCSCTL3 = 0; // FLL Reference Clock = XT1


// Loop until XT1,XT2 & DCO stabilizes - In this case loop until XT1 and DCo settle
do
{
UCSCTL7 &= ~(XT2OFFG + XT1LFOFFG + DCOFFG);
// Clear XT2,XT1,DCO fault flags
SFRIFG1 &= ~OFIFG; // Clear fault flags
}while (SFRIFG1&OFIFG); // Test oscillator fault flag

UCSCTL6 &= ~(XT1DRIVE_3); // Xtal is now stable, reduce drive strength

TA0CTL = TASSEL_1 | TACLR;
TA0CCR0 = 163;
TA0CCTL0 = CCIE;
TA0CTL = TASSEL_1 | MC_1 | TACLR | TAIE;

__bis_SR_register(LPM3_bits + GIE);

}

在上述的的测试代码下,调试时分别在上面的两个中断函数里面打断点,发现两个中断都会进去。

进 TIMER0_A0_VECTOR 中断时,寄存器值如下

进 TIMER0_A1_VECTOR 中断时,寄存器值如下

也就是,在 TA0R 被复位时,定时器会产生 Timer overflow 中断。对于这个 Timer overflow 中断感到不理解,因为这个中断处理会唤醒 CPU 进行处理中断操作,影响程序的功耗,应该怎么去屏蔽这个中断,禁止其生成中断,按照我的理解,这里是不应该产生中断的,因为定时器并没有产生溢出。请问该如何处理,才会不产生该 Timer overflow 中断,谢谢!

  • Timer overflow 中断是来自定时器,发生该中断,才能唤醒处理器进入中断服务程序执行代码。执行完毕中断服务程序,会重新进入低功耗状态的

  • overflow是TIMER产生的,即溢出中断。当timer发生溢出时,产生此中断。溢出的时候你的值很可能都不对了,用中断提醒你,为什么要屏蔽呢~

  • Your final setting of TA0CTL is:

    TA0CTL = TASSEL_1 | MC_1 | TACLR | TAIE;

    That means 65535 ACLKs later, your 16-bit Timer Counter Register will be full and become 0xFFF 0xFFFF (typo corrected). The next ACLK will make it overflow and become 0x0000. Since you also enabled the overflow interrupt by setting TAIE, an overflow interrupt will happen too. This is exactly what happens and it is all your own doing.

    In order to not generate that overflow interrupt, simply change that line of code to not include TAIE in the setting.