📄 msp430x11x1_p2_int.c
字号:
//******************************************************************************
// MSP430x11x1 Demo - Software Port Interrupt Service on P2.0 from LPM4
//
// Description: A hi/low transition on P2.0 will trigger P2_ISR which,
// toggles P1.0. Normal mode is LPM4 ~ 0.1uA. LPM4 current can be measured
// with the LED removed, all unused P1.x/P2.x configured as output or inputs
// pulled high or low, and ensure the P2.0 interrupt input does not float.
// ACLK = n/a, MCLK = SMCLK = default DCO ~ 800k
//
// MSP430F1121
// -----------------
// /|\| XIN|-
// | | |
// --|RST XOUT|-
// /|\ | |
// --o--| P2.0 P1.0|-->LED
// \|/
//
// M. Buccini / Z. Albus
// Texas Instruments Inc.
// May 2005
// Built with Code Composer Essentials Version: 1.0
//*****************************************************************************
#include <msp430x11x1.h>
void main(void)
{
WDTCTL = WDTPW + WDTHOLD; // Stop watchdog timer
P1DIR |= 0x01; // Set P1.0 to output direction
P2IE |= 0x01; // P2.0 interrupt enabled
P2IES |= 0x01; // P2.0 Hi/lo edge
P2IFG &= ~0x01; // P2.0 IFG cleared
_BIS_SR(LPM4_bits + GIE); // Enter LPM4 w/interrupt
}
// Port 2 interrupt service routine
__interrupt void Port_2(void);
PORT2_ISR(Port_2)
__interrupt void Port_2(void)
{
P1OUT ^= 0x01; // P1.0 = toggle
P2IFG &= ~0x01; // P2.0 IFG clearedf
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -