我的板应该使用引脚RB1和RB2,每个读取按钮按下。为此,我通过一个100K电阻将每个引脚连接到3V3
电源线。这两个按钮然后“接地”在电阻器和PIC引脚之间的相应馈电。课本上的东西。我发现插脚总是按压读。一个多表检查显示,每个引脚上的电压大约是1V65,而不是我预期的3V3。在100K电阻之前,万用表读取一个稳定的3V3,所以很明显有东西在拉低电压。最后,作为最小功能测试,我只配置了数字、输出和高电平的引脚。为此,我绝对期望在引脚上看到3V3,但它仍然是1V65。如果情况可能不同的话,我使用PIC18LF46J50。还有一些额外的配置我忽略了吗?谢谢。
以上来自于百度翻译
以下为原文
My board is supposed to use pins RB1 and RB2 to each read a button press. For this I have each pin
tied to the 3V3 power line via a 100K resistor. The two buttons then "ground" the corresponding feed between the resistor and the PIC pin. Textbook stuff.
I found that the pins are always reading as pressed. A multi-meter check reveals that the voltage on each pin is around 1V65 rather than the 3V3 that I was expecting. The multi-meter reads a steady 3V3 BEFORE the 100K resistor, so clearly something is pulling the voltage down.
Finally, as a minimum function test I merely configured the pins for digital, output and high. For this I would definitely expect to see 3V3 on the pins, but it is still 1V65.
Just in case it might make a difference I am using the PIC18LF46J50 .
Is there some additional configuration that I have overlooked?
Thanks.
ANCON1bits.PCFG8 = 1; /* Set RB2/AN8 for digital not analogue */
ANCON1bits.PCFG10 = 1; /* Set RB1/AN10 for digital not analogue */
INTCON2bits.RBPU = 1; /* Disable pull-up resistors just in case */
TRISBbits.TRISB2 = 0; /* Set pins for output */
TRISBbits.TRISB1 = 0;
LATBbits.LATB2 = 1; /* Set pin output = high */
LATBbits.LATB1 = 1;
/* Now I would expect to see 3V3 on the pins but something
* is dragging down the voltage */