This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
程序如下,不知为什么只要手一接触(但还没按,甚至没有碰到P1.3那个开关,),,灯就不停 的闪,,频率超快的
#include <msp430.h>
int main( void )
{
WDTCTL = WDTPW + WDTHOLD;
P1DIR = BIT0 + BIT6 ;
P1OUT &= ~(BIT0 + BIT6);
P1IE |= BIT3;
P1IES |= BIT3;
P1IFG &= ~BIT3;
_EINT();
while(1);
}
#pragma vector =PORT1_VECTOR
__interrupt void Port_1(void)
{
if((P1IFG|0XF7) == 0XFF)
{
P1IFG &= ~BIT3;
P1OUT ^= BIT6;
}
P1OUT |= BIT0;
}
我好像找到问题了,,是因为连接P1.3那个按键是直接通过按键接GND的,,所以会出现不稳定现象,,,,于是我在VCC和P1.3上接了一个上拉电阻,,现在完美解决!
你好,
出现这个问题原因是GPIO管脚是floating的,电平不稳定,你要给他一个稳定的电平,或者上拉,或者下拉,让GPIO管脚电平稳定,这样就不会出现你程序描述的问题了。