问题描述
我正在使用beaglebone通过sysfs接口从特定的引脚访问数字输入.而且我可以更改输出状态,但不能更改输入:(.我要做的是,我有两个引脚pinA和pinB.pinA我使其成为输出,pinB我作为输入.将pinA连接到pinB.通过发送,将pinA配置为输出引脚通过传入传入sysfs和pinB中的direction属性作为输入.然后我将PinA的值更改为1,并给出1作为输出(我使用LED进行了测试).但是,当我读取PinB的值时,它给出的只是0,甚至我将0传递给pinA的值.可能是什么原因?
I am using beaglebone to access digital input from specific pin using sysfs interface. And I can change the output states but not the input :(. What I did is, I have two pins pinA and pinB. pinA I made it output and pinB I made input. Connected pinA to pinB. Configured pinA as output pin by sending out to direction attribute in sysfs and pinB as input by passing in. And I changed value of PinA to 1 and it is giving 1 as output (I tested using LED). But when I read the value of PinB it is giving 0 only, even I pass 0 to value of pinA. what may be the reason ?
谢谢:)
推荐答案
据我了解,您执行的步骤是:
As I understood, the steps you followed:
echo 7 > /sys/kernel/debug/omap_mux/gpmc_ad6
echo 38 > /sys/class/gpio/export
echo in > /sys/class/gpio/gpio38/direction
cat /sys/class/gpio/gpio38/value
我也犯了同样的错误,花了我几个小时,但答案很简单:问题是从"echo 7"开始的第一行.看一下混合位:
I also did the same mistake and it took me hours, but the answer was simple: The first line starting with "echo 7" is the problem. Look at the muxing bits:
Bit 5: 1 - Input, 0 - Output
Bit 4: 1 - Pull up, 0 - Pull down
Bit 3: 1 - Pull disabled, 0 - Pull enabled
Bit 2 \
Bit 1 |- Mode
Bit 0 /
您输入的是回声7,即-> 0 0 0111,它表示:位0,1和2为1,因此已设置模式.没问题.但是,您只是忘记设置它是输入还是输出.它应该是这样的:
You were entering echo 7 which is --> 0 0 0111 and it means: bit 0,1 and 2 is 1, so the mode is set. No problem. However you just forgot to set whether it's an input or output. And it should be like this:
echo 0x27 > /sys/kernel/debug/omap_mux/gpmc_ad6
您的位现在是:1 0 0111二进制,即0x27(十六进制).
your bits are now: 1 0 0111 binary which is 0x27 (hex).
当您输入内容时输入"cat/sys/class/gpio/gpio38/value"时,您会看到一个奇妙的1 :)我相信您会和我一样开心:)
When you write "cat /sys/class/gpio/gpio38/value" while giving input, you can see a wonderful 1 :) I’m sure you will be very happy as much as I was :)
还有一件事,您适合使用约1.8V的模拟输入,但GPIO使用3.3v进行操作.
Also, one more thing, you are right for Analog input about 1.8V, but GPIO operates with 3.3v.
这篇关于Beaglebone GPIO输入无法正常工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!