我可以从图 18f4550 的 PORTBbits.RB7 中获取哪个值

发布于 2024-10-25 01:54:11 字数 207 浏览 9 评论 0原文

我可以从 PORTBbits.RB7 得到哪个值,在这个端口上有一个连接了电阻的绿色 LED(见图)。我使用 pic F184550 和 mplab ide v8.63 以及来自 mplab microchip 的 C 编译器 C18。或者我是否需要写信给腻子才能看到这个值。谢谢 在此处输入图像描述

Which value can I expect from PORTBbits.RB7, on this port there is a green led with a resistor connected (see picture). I'm using pic F184550 with mplab ide v8.63 and a C compiler C18 from mplab microchip. Or do I need to write to putty to see this value. thanks enter image description here

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

风吹短裙飘 2024-11-01 01:54:11

简短的答案取决于 PORTB7 引脚上测量的电压,答案将为 0、1 或两者。

其原因在于数字 GPIO 引脚的工作方式。为了确定该引脚上的给定电压会产生 0 还是 1,芯片制造商设置了一个阈值。对于 PIC18:

0.8 * Vdd == 数字“1”

0.2 * Vdd == 数字“0”

其中Vdd是电源电压

因此,如果 Vdd == 3.3V,则 PORTB7 两端的电压需要为 2.64V 或以上才能读取为数字 ' 1'。 0 - 0.66V 的电压将被读取为数字“0”。

如果电压介于这两个阈值之间怎么办?谁知道?您只知道您有两个选择:0 或 1。

现在,如果您想读取 PORTB7 的实际电压电平,那么不幸的是您运气不好。您需要将该电压电平连接到 ADC 才能获取该信息。

The short answer would be depending on the voltage that is measured on the PORTB7 pin, the answer will be a 0, 1, or both.

The reason for that is because of the way a digital GPIO pin works. To determine whether a given voltage across that pin results in a 0 or a 1, a threshold is set by the chip manufacturer. For the PIC18:

0.8 * Vdd == Digital '1'

0.2 * Vdd == Digital '0'

Where Vdd is the supply voltage

So if Vdd == 3.3V, the voltage across PORTB7 needs to be 2.64V or above to be read as a digital '1'. A voltage of 0 - 0.66V will be read as a digital '0'.

What if the voltage is somewhere in between those two thresholds? Who knows? All you know is that you have two choices: 0 or 1.

Now if you're looking to read the actual voltage level off of PORTB7 then unfortunatley you're out of luck. You'll need to connect that voltage level to an ADC to be able to get that information.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文