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.
wo想问一下,在什么情况下才需要时能PxREN上拉电阻呢?我看例程里面测试P1.4的程序没有使能上拉电阻直接用if ((0x10 & P1IN),我想用P1.3的按键时,就需要先使能上拉电阻才能检测到按键,不使能的话,按键状态无法检测。测试P1.4和P1.3的按键有什么输入方式的不同吗?为什么P1.4的检测可以不用使能上拉电阻,而P1.3要使用呢?使能是因为驱动电流不够?那P1.4不使能也可以?
int main(void)
{
WDTCTL = WDTPW + WDTHOLD; // Stop watchdog timer
P1DIR |= 0x01;
//P1DIR &=~BIT3;// Set P1.0 to output direction
while (1) // Test P1.4
{
if ((0x10 & P1IN)) P1OUT |= 0x01; // if P1.4 set, set P1.0
else P1OUT &= ~0x01; // else reset
}
}