简体   繁体   English

TIMER0 不执行多个比较匹配寄存器中断请求。(MSP430)

[英]TIMER0 not executing multiple compare match register interrupt requests.(MSP430)

OK so I have been attempting to create some code using a MSP430FR5994 TI launch pad that utilizes Timer0 and 3 separate compare registers to trigger 3 separate isr's.好的,所以我一直在尝试使用 MSP430FR5994 TI 启动板创建一些代码,该启动板利用 Timer0 和 3 个单独的比较寄存器来触发 3 个单独的 isr。 I have successfully got one to work however as soon as I add another compare register the CCIFE flag sets and never competes the execution of the second isr.我已经成功地让一个工作,但是一旦我添加另一个比较寄存器,CCIFE 标志设置并且永远不会竞争第二个 isr 的执行。 I have watched the code in the debugger on both CCstudio and IAR same thing happens in both, the set up registers are correct and the TA0R registers is counting and will trigger the first isr based on the TA0CCR0 but all other compare regs R1 2 3 etc will not trigger and execute successfully.我已经在 CCstudio 和 IAR 的调试器中观察了代码,两者都发生了同样的事情,设置寄存器是正确的,TA0R 寄存器正在计数,并将触发基于 TA0CCR0 的第一个 isr,但所有其他比较 regs R1 2 3 等不会触发和执行成功。 The code is below, idea's on what I am doing wrong would be much appreciated.代码如下,非常感谢我做错了什么。

#include "msp430.h"
#include <stdbool.h>
#define COUNT_1 12000 
#define COUNT_2 800


int main( void )
{
  // Stop watchdog timer to prevent time out reset
  WDTCTL = WDTPW + WDTHOLD;

  PM5CTL0 &= ~LOCKLPM5;

  P1DIR |= BIT0 + BIT1;
  P1OUT = BIT0 + BIT1; 


   //set up and enable timer A or TA0 for continous mode 

  TA0CCR0 = COUNT_1;
  TA1CCR1 = COUNT_2;  
  TA0CTL = TASSEL__ACLK + MC_2;  //set the max period for 16bit timer operation
  TA1CTL = TASSEL__ACLK + MC_2;
  TA0CCTL0 = CCIE;  //enable compare reg 0
  TA1CCTL1 = CCIE;  //enable compare reg 1
  //TA0CTL |= TAIE;

  _BIS_SR( GIE); //ENABLE GLOBAL INTERRRUPTS

  //set the max period for 16bit timer operation


  while(true){}


  }

#pragma vector= TIMER0_A0_VECTOR    //compare interrupt 0 flahse red led
__interrupt void TIMER0_A0(void) {
  P1OUT ^= BIT1 ;

}

#pragma vector = TIMER1_A1_VECTOR   //compare interrupt 1 flashes green led
__interrupt void TIMER1_A1(void) {

 P1OUT ^= BIT0;

}

The User's Guide says in section 25.2.6.1:用户指南在第 25.2.6.1 节中说:

The TAxCCR0 CCIFG flag is automatically reset when the TAxCCR0 interrupt request is serviced.当 TAxCCR0 中断请求被处理时,TAxCCR0 CCIFG 标志自动复位。

However, this does not happen for the other CCRx interrupts, because multiple ones use the same interrupt vector.但是,其他 CCRx 中断不会发生这种情况,因为多个中断使用相同的中断向量。 Section 25.2.5.2 says:第 25.2.5.2 节说:

The highest-priority enabled interrupt generates a number in the TAxIV register (see register description).启用的最高优先级中断在 TAxIV 寄存器中生成一个数字(参见寄存器说明)。 […] […]
Any access, read or write, of the TAxIV register automatically resets the highest-pending interrupt flag.对 TAxIV 寄存器的任何访问(读取或写入)都会自动复位最高挂起的中断标志。

So you always have to read the TAxIV register (and with three or more CCRs, you need it to find out which CCR triggered the interrupt):因此,您始终必须读取 TAxIV 寄存器(并且对于三个或更多 CCR,您需要它来找出哪个 CCR 触发了中断):

__interrupt void TIMER1_A1(void) {
    switch (TA1IV) {
    case TAIV__TACCR1:
        P1OUT ^= BIT0;
        break;
    case TAIV__TACCR2:
        ...
        break;
    }
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM