简体   繁体   English

MSP430 - 如何将定时器 A1 中断用于不同目的?

[英]MSP430 - how to use timer A1 interrupts for different purposes?

Is it possible to use timer A1 interrupts for different purposes with different set of lines?是否可以将定时器 A1 中断用于不同的线路集的不同目的?

I get error message that I am declaring the timer A1 interrupts, that I have duplicate declaration.我收到错误消息,说我声明了计时器 A1 中断,我有重复的声明。 My code has a low power interrupt using timer A1, and An RC charging and discharging circuit which should use timer A1 interrupt.我的代码有一个使用定时器 A1 的低功率中断,以及一个应该使用定时器 A1 中断的 RC 充电和放电电路。

Is it possible to have duplicate timer interrupts and how it can be done?是否可能有重复的定时器中断以及如何完成?

You can set up multiple capture and compare registers (CCR) for the timer A1.您可以为定时器 A1 设置多个捕捉和比较寄存器 (CCR)。 Each application could use its own.每个应用程序都可以使用自己的。 Then in the handler demultiplex by looking at TAIV .然后在处理程序中通过查看TAIV路分解。 From TI sample code for msp430f1611:来自 msp430f1611 的 TI 示例代码:

void __attribute__ ((interrupt(TIMERA1_VECTOR))) Timer_A1 (void)
{
  switch( TAIV )
  {
  case  2: CCR1 += 1000;                    // Add Offset to CCR1
           break;
  case  4: CCR2 += 10000;                   // Add Offset to CCR2
           break;
  case 10: P1OUT ^= 0x01;                   // Timer_A1 overflow
           break;
 }
}

This MCU has three registers: CCR0, CCR1, and CCR2.该 MCU 具有三个寄存器:CCR0、CCR1 和 CCR2。 Timer A1 interrupt handler is called for CCR1, CCR2, and on overflow of the timer counter ( TAR ).针对 CCR1、CCR2 和定时器计数器 ( TAR ) 溢出调用定时器 A1 中断处理程序。 CCR0 is handled by a separate interrupt handler (A0). CCR0 由单独的中断处理程序 (A0) 处理。

Don't try to overwrite the interrupt vector during runtime - that's a terrible idea.不要试图在运行时覆盖中断向量 - 这是一个糟糕的主意。 On msp430 it also requires reprogramming (part of) the flash.在 msp430 上,它还需要重新编程(部分)闪存。 Instead, write a single handler and differentiate the application-specific logic inside it.相反,编写单个处理程序并区分其中的特定于应用程序的逻辑。

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

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