大家好!最近在做一个项目,用到430G2系列MCU.有个问题一直想不通?
因为超低功耗用430,IO作为初始检测,流程如下:
1.设P1DIR输入
2.设P1REN上拉
3.检测IO状态
4.设P1DIR输出
5.关闭IO
在3状态时,检测IO状态不稳定,有时高有时低?后在状态2后面把P1OUT设置为输出高,正常?
请问这是正确流程吗?
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.
代码如下:
void ProtInit(void)
{
P1DIR |=BIT3;
P1DIR |=BIT4;
P1DIR |=BIT5;
P1REN |=BIT0;
P1REN |=BIT1;
P1OUT |=BIT0;
P1OUT |=BIT1;
P1IES =0; //P1.2中断上升沿触发器
P1IFG =0;
if((PinA==0)&&(PinB==0)) //AB都接地;测试模式
{
Mode=3;
}
else if((PinA!=0)&&(PinB==0))
{
Mode=0;
}
else if((PinB!=0)&&(PinA==0))
{
Mode=1;
}
else if((PinA!=0)&&(PinB!=0))
{
Mode=2;
}
P1REN =0;//取消所有上拉
P1DIR =0XFB;
P1OUT &=~BIT0;
P1OUT &=~BIT1;
}
红色两句代码加上后,IO口状态才稳定,这是TI的MCU的正确工作方式吗?其它的单片机只要设置为输入,设置为上拉电阻后,就是高电平了。