zoukankan      html  css  js  c++  java
  • MSP430 G2553 Timer 中断总结

    目前总共用到了四个中断向量,我觉得已经把G2553的所有定时器中断都用到了。

    定时器有两个,TA0与TA1,每个定时器又有两个中断向量

    1,CCR0到达时的中断,在计数模式时候很有用,平时定时器的基本功能。

    2,CCR1,CCR2,以及 overflow时候的中断向量,这里面又有三个中断标志。

    #define TIMER0_A1_VECTOR (8 * 2u) /* 0xFFF0 Timer0)A CC1, TA0 */

    #define TIMER0_A0_VECTOR (9 * 2u) /* 0xFFF2 Timer0_A CC0 */ . .

    #define TIMER1_A1_VECTOR (12 * 2u) /* 0xFFF8 Timer1_A CC1-4, TA1 */

    #define TIMER1_A0_VECTOR (13 * 2u) /* 0xFFFA Timer1_A CC0 */

     
    可见,每个TimerA模块有两个中断向量
    更详细一点,查阅用户指南可知:
    TIMERA0只针对CCR0的计数溢出
    TIMERA1再查询TAIV后可知道是CCR1,还是CCR2,亦或TAIFG引起的,至于TAIFG是什么情况下置位的,则要看TA工作的模式

    TA0的两个中断:

    #pragma vector=TIMER0_A0_VECTOR

    __interrupt void TimerA0(void)

    {

        //计数到达时候的代码

    }

    #pragma vector=TIMER0_A1_VECTOR

    __interrupt void Timer0_A(void)

    {

     switch( TA0IV )    //TAIV中断向量寄存器  用于

     {

       case  2: break;                          // CCR1 not used   捕获/比较器1

       case  4: break;                          // CCR2 not used    捕获/比较器2

       case 10: break;                  // overflow  定时器溢出            

     }

    下面是TA1的两个中断向量,注意向量名字。

    #pragma vector=TIMER1_A0_VECTOR

    __interrupt void TimerA1(void)

    {

      //计数到达时候的代码

    }

    #pragma vector=TIMER1_A1_VECTOR      //Timer1_A CC1  的中断向量

    __interrupt void Timer_A1(void)

    {  unsigned int count;  char countH,countL;  float mile;  UCHAR shi[2];        //的方法进行判断是哪一个中断源产生的中断

      switch(TA1IV)    //如果是Timer1_A CC1产生的中断

      {

        case 2:   break;    // CCR1 not used   捕获/比较器1

        case 4:break;  // CCR2 not used    捕获/比较器2

        case 10:break; // overflow  定时器溢出

       }

    另外TA1与TA2的寄存器名字也有不同设置时候需要注意

  • 相关阅读:
    123. Best Time to Buy and Sell Stock III (Array; DP)
    122. Best Time to Buy and Sell Stock II (Array;Greedy)
    121. Best Time to Buy and Sell Stock (Array;DP)
    38. Count and Say (String; DP)
    60. Permutation Sequence (String; Math)
    内存中的堆栈
    42. Trapping Rain Water (Array,stack; DP)
    84. Largest Rectangle in Histogram (Array, Stack; DP)
    85. Maximal Rectangle (Graph; Stack, DP)
    Effective C++ .44 typename和class的不同
  • 原文地址:https://www.cnblogs.com/wwjdwy/p/3240784.html
Copyright © 2011-2022 走看看