1212 views|0 replies

3836

Posts

19

Resources
The OP
 

msp430 button control LED light [Copy link]

#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 be on again.
P4OUT ^= BIT5; //On and off cycle
P4IFG &= ~BIT2;
}

This post is from Microcontroller MCU
 

Guess Your Favourite
Just looking around
Find a datasheet?

EEWorld Datasheet Technical Support

Related articles more>>
Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京B2-20211791 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号
快速回复 返回顶部 Return list