您好,我现在用着MSP430G2553 launchpad 学习。想通过IO中断,引入外部脉冲信号,使LED灯随着信号脉冲上升延闪烁。1、请问有没有如上述现象的例程参考一下。2、还有我用了如下例程,在用直流电源间歇触碰P1.4口模拟脉冲信号,为什么我触到端口和撤离端口,灯都会变?正常的话应该只能变一次啊。3、是不是加的信号,高电平应该大于零,低电平应该等于0?可以小于零吗?
//******************************************************************************
// MSP430G2xx3 Demo - P1 Interrupt from LPM4 with Internal Pull-up
//
// Description: A hi/low transition on P1.4 will trigger P1_ISR which,
// toggles P1.0. Normal mode is LPM4 ~ 0.1uA.
// Internal pullup enabled on P1.4.
// ACLK = n/a, MCLK = SMCLK = default DCO
//
// MSP430G2xx3
// -----------------
// /|\| XIN|-
// | | |
// --|RST XOUT|-
// /|\ | R |
// --o--| P1.4-o P1.0|-->LED
// \|/
//
// D. Dang
// Texas Instruments Inc.
// December 2010
// Built with CCS Version 4.2.0 and IAR Embedded Workbench Version: 5.10
//******************************************************************************
#include <msp430g2553.h>
void main(void)
{
WDTCTL = WDTPW + WDTHOLD; // Stop watchdog timer
P1DIR = 0x01; // P1.0 output, else input
P1OUT = 0x10; // P1.4 set, else reset
P1REN |= 0x10; // P1.4 pullup
P1IE |= 0x10; // P1.4 interrupt enabled
P1IES |= 0x10; // P1.4 Hi/lo edge
P1IFG &= ~0x10; // P1.4 IFG cleared
_BIS_SR( GIE); // Enter LPM4 w/interrupt
}
#pragma vector=PORT1_VECTOR
__interrupt void Port_1(void)
{
P1OUT ^= 0x01; // P1.0 = toggle
P1IFG &= ~0x10; // P1.4 IFG cleared
}