jadonk / jadonk/rowboat

Can't read GPIO

Open
#115 0 comments 0 reactions 0 assignees View on GitHub
auto-migrated Priority-Medium Type-Defect
Dominant language
No language data
Stars
0
Forks
0
PR merge metrics
No merged PRs in 30d

Description

```
What steps will reproduce the problem?
I have the following bits of code:
// Setup the pin mux
volatile unsigned long *pinconf;
pinconf = (unsigned long*) mmap(NULL, 0x10000, PROT_READ | PROT_WRITE,
MAP_SHARED, fd, 0x48000000);
pinconf[0x2158/4] = 0x010C0004;

// Setup the GPIO registers
volatile unsigned long *gpio;
gpio = (unsigned long*) mmap(NULL, 0x10000, PROT_READ | PROT_WRITE, MAP_SHARED,
fd, 0x49050000);
// Make GPIO_131 input and GPIO_130 output (0 - output, 1 - input)
gpio[0x6034/4] |= (1 << 4);
gpio[0x6034/4] &= ~(1 << 3);
// Set GPIO_130
gpio[0x6094/4] = (1 << 3);

I have a BeagleBoard running Rowboat Froyo and I am running that code in root
shell. There is a push-button connected between the two GPIO pins. GPIO_130 is
outputting 1 and GPIO_131 is supposed to be pulled-down input idling low and
staying high when the button is pressed.

What is the expected output? What do you see instead?

I am trying to poll the state of the button with this code:
if ((gpio[0x6038/4] & (1 << 4)) == 0) {
printf("Button is up (%X)\n", gpio[0x6038/4]);
} else {
printf("Button is down (%X)\n", gpio[0x6038/4]);
}

The problem is that the button is always reported up no matter what the actual
state is. It seems that the output control works (I can both write and read the
output's state) but the input reading is not affected by the voltage present at
the pin. I have done measurements with my multimeter and thereby confirmed that
the signaling works i.e. the output works and the pull-down draws current.

What version of the product are you using? On what operating system?
BeagleBoard rev. B and Rowboat Froyo.

Please provide any additional information below.
I have tried the very same polling in both user-space and kernel-space and
neighter seems to work for the very same reason.

```

Original issue reported on code.google.com by `antti.ga...@gmail.com` on 5 Jul 2011 at 9:54

Contributor guide

No contributing guide indexed for this repository

Research direction

Start with the pin-mux setup, GPIO register mappings, and polling expression in the reported C example, using the BeagleBoard rev. B and Rowboat Froyo context. Verify that the configured input register reflects the measured pin voltage and that the button state changes the reported value; done means polling distinguishes the button's up and down states.

Written by the indexing model from the issue text.

Assessment

Tech stack
c
Domain
embedded-iot
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.