|
MSP430 LaunchPad IO外部中断
[复制链接]
- #include
-
-
- int main( void )
- {
- // Stop watchdog timer to prevent time out reset
- WDTCTL = WDTPW + WDTHOLD;
-
- P1DIR |= 0x01;//设置P1.0口为输出
- P1IE |= 0x08;//使能P1.3中断
- P1IES |= 0x08;//P1.3口下降沿触发中断
- P1IFG &= ~0x08;//中断标志位清零
-
-
- _EINT();//开总中断
- //_BIS_SR(LPM4_bits + GIE);
- while(1)
- {
- }
- }
-
-
- /*中断服务程序*/
- #pragma vector = PORT1_VECTOR
- __interrupt void PORT_1(void)
- {
- P1OUT ^= 0x01;//P1.0状态翻转
- P1IFG &= ~0x08;//中断标志位清零
- }
|
|