#pragma这个预定义兼容性并不好,我是其他产品转到430上来的,很不习惯这个指令。而且不适宜移植。请问CCS能够使用其他方式定义中断吗?比如像51或者STM32那样子。
附一段例程:
#include <msp430.h>
int main(void)
{
WDTCTL = WDTPW + WDTHOLD; // Stop watchdog timer
P1DIR |= BIT0; // Set P1.0 to output direction
P1REN |= BIT4; // Enable P1.4 internal resistance
P1OUT |= BIT4; // Set P1.4 as pull-Up resistance
P1IES |= BIT4; // P1.4 Hi/Lo edge
P1IFG &= ~BIT4; // P1.4 IFG cleared
P1IE |= BIT4; // P1.4 interrupt enabled
__bis_SR_register(LPM4_bits + GIE); // Enter LPM4 w/interrupt
__no_operation(); // For debugger
}
// Port 1 interrupt service routine
#pragma vector=PORT1_VECTOR
__interrupt void Port_1(void)
{
P1OUT ^= BIT0; // P1.0 = toggle
P1IFG &= ~BIT4; // P1.4 IFG cleared
}
关东糖:
回复 Susan Yang:
了解了,谢谢!