GPIO on P6

Discussion related to "under the hood" OpenMV topics.
User avatar
kwiley
Posts: 107
Joined: Fri Dec 21, 2018 5:22 pm

GPIO on P6

Postby kwiley » Fri Jan 18, 2019 2:35 pm

P6 is the DAC/ADC line, in addition to a timer. But doesn't it have to be configured for DAC/ADC first? If I just assign it as a GPIO, shouldn't it act like a GPIO? I ask because that's not what I observe. If I set it to a pull-down, it remains up, but if I set it to a pull-up, I can pull it down with a switch. So it doesn't "respond correctly" to a switch, the way, say, P4 and P5 do, which both respond to a switch correctly in both pull-up or pull-down fashion.

I just hooked a momentary switch between pins 4, 5, or 6 and the 3.3V rail for a pull-down/switch-up test and the ground rail for a pull-up/switch-down test...which I presume was the proper arrangement.

Is there any overarching electronic philosophy as to whether it is better to configure switches in a pull-up/switch-down fashion or the other way around?
User avatar
kwagyeman
Posts: 3207
Joined: Sun May 24, 2015 2:10 pm

Re: GPIO on P6

Postby kwagyeman » Fri Jan 18, 2019 3:41 pm

Hi, it should act as a GPIO with pull ups and downs. That could be a bug. Please create a bug on GitHub about this and Ibrahim will take a look and fix it.

As for using pull ups or downs. For switches there's no particular way you have to go. Most folks do pull ups with a switch pulling to ground however.
Nyamekye,
User avatar
kwiley
Posts: 107
Joined: Fri Dec 21, 2018 5:22 pm

Re: GPIO on P6

Postby kwiley » Fri Jan 18, 2019 7:49 pm

It could also be this Chinese knock off board I'm working with. I already pointed out that the darn LED is soldered on wrong. :D
User avatar
kwiley
Posts: 107
Joined: Fri Dec 21, 2018 5:22 pm

Re: GPIO on P6

Postby kwiley » Sat Jan 19, 2019 11:25 am

I'm quite certain that what's going on is I'm doubling up on the LCD's backlight control by accident. I realize there is some discussion elsewhere about disabling the backlight control pin to provide an additional GPIO, but even without doing that, the pin can still be used as a switch, but only in the pull-up/switch-down fashion. Wired that way, you can detect when the button is down (but of course the LCD briefly goes dark while you press the button). This is sufficient for a momentary switch for providing instantaneous binary signals to the program (for example, to increment a counter or trigger some other single function call and behavior).

So, I have three functional switches at lines P4, P5, and P6. In theory, I would have four if I count P9, but I'm using that for SPI-select to a second SPI device. I've found a Qwiic-interfaced I2C keypad on Sparkfun (https://www.sparkfun.com/products/14836). If I can get that to work, then I can use 12 buttons through just two wires. Presumably I don't *have* to use some sort of Qwiic environment for that keypad. I should be able to use the keypad directly (realizing that all Qwiic does is simplify the GPIO-to-I2C layer that I have no particular interest in hacking up through, say, https://www.sparkfun.com/products/13601, as recommended in another thread). So that will be the next thing I try.
User avatar
kwagyeman
Posts: 3207
Joined: Sun May 24, 2015 2:10 pm

Re: GPIO on P6

Postby kwagyeman » Sat Jan 19, 2019 12:06 pm

I2C I/O expansion is the way to go. It just is the easiest way to add a ton of stuff.
Nyamekye,
User avatar
kwiley
Posts: 107
Joined: Fri Dec 21, 2018 5:22 pm

Re: GPIO on P6

Postby kwiley » Sat Jan 19, 2019 12:10 pm

Yes, but I'm lazy! :D
User avatar
iabdalkader
Posts: 918
Joined: Sun May 24, 2015 3:53 pm

Re: GPIO on P6

Postby iabdalkader » Sat Jan 19, 2019 9:29 pm

There was something different about this pin in the datasheet, let me check and get back to you.

EDIT: No actually other than something about current injection, it looks normal. If you're still having a problem post the code and I'll test it.

Return to “Technical Discussion”

Who is online

Users browsing this forum: No registered users and 45 guests