MSP430 MCU interrupt control flashing light

Publisher:温暖微笑Latest update time:2015-06-18 Source: 51heiKeywords:msp430 Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere
/*******************************************************************************

                                               Flashing light with interrupt
******************************************************************************/ 
#include
/****************************************
msp430G2553 controls the flashing of two LEDs connected to P1.0 and P1.6
The flashing effect can be set in array form, and the array value is assigned to output P1 in a loop.
******************************************/
char dis[12]={0x41,0x00,0x41,0x00,0x01,0x00,0x40,0x00,0x40,0x00,0x01,0x00};
//Define an array dis[12] with 12 elements, which can store 12 display states
int n,t,m;
void delay()
/*Set a custom function. If it is set before the main program, it can be set directly. If it is set after the main program, it must be declared before the main program Declare it before the main program
, and then set it after the main program*/
{
  while(t--);
}
void main(void)
{
  
 WDTCTL = WDTPW + WDTHOLD; // Stop watchdog_EINT
 ();
 P1DIR &=~BIT3;
 P1IE |= BIT3;
 P1IES |=BIT3;
 P1IFG =0x00;
 P1DIR |=(BIT0+BIT6);//Set P1.0 and P1.6 as outputs, and the rest of the states remain unchangedwhile
(1)
   {
     for (n=0;n<12;n++)
        {
           P1OUT=dis[n]; 
            delay(100);
        }
   }
}

#pragma vector=PORT1_VECTOR
   __interrupt void MM(void)
   { 
     if ((P1IFG & BIT3)==BIT3)
     {
     P1OUT |=BIT0;
     for (m=1;m<15;m++)
         {
         P1OUT^=(BIT0);
         delay(5);
         }
     }
     P1IFG &=0x00;
   }

Keywords:msp430 Reference address:MSP430 MCU interrupt control flashing light

Previous article:Stepper motor driver assembly program and debugging summary
Next article:MSP430 MCU drives LCD1602 C language program

Latest Microcontroller Articles
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号