MSP430F249_TimerA timer

Publisher:国宝集团Latest update time:2017-11-25 Source: eefocusKeywords:MSP430F249  TimerA  Timer Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

/******************************************************************
**                                                       
**  File : TimerA.c     | Timer Interrupt |                                    
**  Version : 1.0     
** Description: TimerA Interrupt                                                                          
**  Author : LightWu                              
**  Date : 2013-4-16                                                       
**                                                   
*******************************************************************/


#include "MSP430X24X.h"


int Count;


void main(void)
{
        // Stop watchdog timer to prevent time out reset
        WDTCTL = WDTPW + WDTHOLD;       //关狗
  
        P4DIR = BIT0|BIT1|BIT2|BIT3;    //设置为输出
        P4SEL = 0;
        
        P1IE |= 0x08;                             // P1.3 interrupt enabled
        P1IES |= 0x08;                            // P1.3 Hi/lo edge
        P1IFG &= ~0x08;                           // P1.3 IFG cleared


        //__bis_SR_register(LPM4_bits + GIE);       // Enter LPM4 w/interrupt
        
        CCTL0 = CCIE;                             // CCR0 interrupt enabled
        CCR0 = 10;
        TACTL = TASSEL_2 + MC_2;                  // SMCLK, contmode


        _BIS_SR(LPM0_bits + GIE);                 // Enter LPM0 w/ interrupt
        
        while(1)
        {
              if( 10 < Count )
              {
                  Count = 0;
                  
                  P4OUT ^= 0x0F;              //电平翻转
              }
        }
        
}


// Port 1 interrupt service routine
#pragma vector=PORT1_VECTOR
__interrupt void Port_1(void)
{
    P4OUT ^= 0x0F;              //电平翻转
    
    P1IFG &= ~0x08;             // P1.3 IFG cleared,注意清标志位,否则会一直进入中断
}


// Timer A0 interrupt service routine
#pragma vector=TIMERA0_VECTOR
__interrupt void Timer_A (void)
{
    //P4OUT ^= 0x0F;              //电平翻转
    
    Count++;
    if( 10 < Count )
    {
         __bic_SR_register_on_exit(LPM0_bits);        // Exit LPM0


    }
 
}

Keywords:MSP430F249  TimerA  Timer Reference address:MSP430F249_TimerA timer

Previous article:MSP430F249 hardware I2C query method to read and write AT24C02
Next article:MSP430F249 external interrupt P1.3 port

Latest Microcontroller Articles
  • Download from the Internet--ARM Getting Started Notes
    A brief introduction: From today on, the ARM notebook of the rookie is open, and it can be regarded as a place to store these notes. Why publish it? Maybe you are interested in it. In fact, the reason for these notes is ...
  • Learn ARM development(22)
    Turning off and on interrupts Interrupts are an efficient dialogue mechanism, but sometimes you don't want to interrupt the program while it is running. For example, when you are printing something, the program suddenly interrupts and another ...
  • Learn ARM development(21)
    First, declare the task pointer, because it will be used later. Task pointer volatile TASK_TCB* volatile g_pCurrentTask = NULL;volatile TASK_TCB* vol ...
  • Learn ARM development(20)
    With the previous Tick interrupt, the basic task switching conditions are ready. However, this "easterly" is also difficult to understand. Only through continuous practice can we understand it. ...
  • Learn ARM development(19)
    After many days of hard work, I finally got the interrupt working. But in order to allow RTOS to use timer interrupts, what kind of interrupts can be implemented in S3C44B0? There are two methods in S3C44B0. ...
  • Learn ARM development(14)
  • Learn ARM development(15)
  • Learn ARM development(16)
  • Learn ARM development(17)
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号