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.

[参考译文] MSP430G2553:G2553捕捉示例

Guru**** 2562980 points


请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

https://e2e.ti.com/support/microcontrollers/msp-low-power-microcontrollers-group/msp430/f/msp-low-power-microcontroller-forum/683665/msp430g2553-g2553-capture-example

器件型号:MSP430G2553

大家好、

有人能否向我展示一个在 CAP 模式下使用 TimerA0_3的简单示例? 如 x2xx 系列用户指南12.2.4中所述、我想进行速度计算。 我不确定如何处理中断。  

这是我到目前为止拥有的代码。 我想在 CCIS 上触发一个中断。

//使用 P1.6输出进入捕捉 CCIS TimerA0_3
// MSP430G2xx3
// --------
// | |-
// | |
// -|P1.1/CCI0A |-
// || |
// || P1.6|--
// | |
// _________________________________ |///*********




#include 
volatile int count;
int main (void)
{
WDTCTL = WDTPW + WDTHOLD; //停止 WDT
TA0CTL = tassel_2 + MC_2 + TACLR;// SMCLK、向上计数模式
TACCTL0 = CAP + CM_1 + CCIE;// CAP、内部 启用
P1SEL |= BIT1;// TA0.CCI0A
P1DIR |= BIT6;//脉冲生成。 进入 CCIS
_bis_SR_register (GIE);

while (1){
P1OUT ^= BIT6;//查看 TAR 递增的周期数
}



// Timer_A3中断向量(TA0IV)处理程序
#if defined (__TI_Compiler_version__)|| defined (__IAR_systems_icc_)
#void TI_COMPIAR (timer_A
)#interrupt



(timer_A void)#TI_timer_A (timer_A!#tine_vector (timer_a void)(timer_a timer_a timer_a timer_a timer_a timer_a timer_a!(void)(timer_a timer_a timer_a timer_interrupt)#tine_vector (void)
#endif
{
switch (TA0IV)
{
case 2:
count++;
break; //
案例4:中断; // CCR2未使用
案例10: //未使用
中断;
}

谢谢、

Scott

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。
    CCR0有其自己的 ISR、其中 vector=TIMER0_A0_vector。 TA0CCTL0:CCIE 在进入 ISR 时被复位、所以不要读取 TA0IV。

    我还建议设置 TA0CCTL0:SCS、尽管我忘记了原因(旧习惯)。

    TI 捕获示例为 msp430g2xx3_TA_21.c (在 SLAC485D 中、通过产品页面上的"软件和工具"选项卡)。