zoukankan      html  css  js  c++  java
  • Timer A UP mode 中断

    Timer_A, Toggle P1.0, CCR0 Up Mode ISR, DCO SMCLK

    //  Description: Toggle P1.0 using software and TA_0 ISR. Timer_A is
    //  configured for up mode, thus the timer overflows when TAR counts to CCR0.

    1 void Timer0_Init(void)
    2 {
    3 
    4       CCTL0 = CCIE;                             // CCR0 interrupt enabled
    5       CCR0 = 5000;                              //frequency SMCLK/5000*2;
    6       TACTL = TASSEL_2 + MC_1;                  // SMCLK, upmode
    7 }
    void Timer0_Init(void)

    中断函数

    1 #pragma vector=TIMER0_A0_VECTOR
    2 
    3 __interrupt void TimerA0(void)
    4 
    5 {
    6 
    7     P1OUT ^= RED_LED;
    8 
    9 }
    __interrupt void TimerA0(void)

    屏蔽中断:
    CCTL0 ^=  CCIE; //在开启定时器中断与关闭间转换。

    因为同时使用的PWM与此定时器冲突所以又使用了定时器A1

     1 void Timer1_Init()
     2 
     3 {
     4 
     5 TA1CCTL0 = CCIE;
     6 
     7 TA1CCR0 = 5000;    
     8 
     9 TA1CTL |= TASSEL_2+MC_1+TACLR;  
    10 
    11 }
    void Timer1_Init()

    中断

    1 #pragma vector=TIMER1_A0_VECTOR
    2 
    3 __interrupt void TimerA1(void)
    4 
    5 {
    6 
    7     P1OUT ^= RED_LED;
    8 
    9 }
    __interrupt void TimerA1(void)

    注意寄存器名字与中断向量的名字

  • 相关阅读:
    CF1368F
    CF1083F
    AGC030F
    AGC030E Less than 3
    CF1083C
    CF526G
    CF1408
    CF1408H Rainbow Triples
    CF1408I
    AGC019E
  • 原文地址:https://www.cnblogs.com/wwjdwy/p/3240670.html
Copyright © 2011-2022 走看看