msp430 button control LED light

Publisher:和谐共处Latest update time:2018-07-14 Source: eechinaKeywords:msp430 Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

#include "io430.h"

/*

       There are two ways to control the on and off of the LED light.

       Method 1: Interrupt function. Method 2: Use if(P4IN&BIT2) to judge.

       When writing code, try to follow the steps to avoid wasting a lot of time looking for bugs due to negligence.

*/

int main( void )

{

  // Stop watchdog timer to prevent time out reset

  WDTCTL = WDTPW + WDTHOLD;

  P4DIR |= BIT5;

  P4REN |= BIT2;

  P4OUT |= BIT2;

  P4IES |= BIT2;

  P4IFG &= ~BIT2;

  P4IE |=BIT2;

 

   __bis_SR_register(LPM4_bits+GIE);

  

  return 0;

#pragma vector=PORT4_VECTOR

 __interrupt void Port_4(void)

{

  //P4OUT &= ~BIT5; //If it is off, it can't light up again.

  P4OUT ^= BIT5; //on and off cycle

  P4IFG &= ~BIT2;

}


Keywords:msp430 Reference address:msp430 button control LED light

Previous article:MSP430G2553 1602 display characters
Next article:MSP430G2553 electronic clock experiment

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号