MSP430F1101A单片机按键及LED的检测程序
[复制链接]
主要实现MSP430F1101A单片机的时钟设置及按键对应LED的显示
单片机源程序如下:
#include <msp430x11x1.h>
int main( void )
{
// Stop watchdog timer to prevent time out reset
WDTCTL = WDTPW + WDTHOLD;
P2DIR |= 0X01;
P2OUT |= BIT0;
P1DIR &= ~BIT0;
P1IE |= 0X01;
P1IES |= 0X01;
P1IFG &= ~0X01;
_BIS_SR(LPM4_bits+GIE);
}
# pragma vector=PORT1_VECTOR
__interrupt void port_1(void)
{
unsigned int i;
if (!(P1IN & BIT0))
{
for(i=0;i<8000;i++);
if (!(P1IN & BIT0))
{
P2OUT &= ~BIT0;
while(!(P1IN & BIT0));
P2OUT |= BIT0;
}
}
//P2OUT ^= 0X01;
P1IFG &= ~0X01;
}
|