esteimle
Posts: 10
Joined: Tue Nov 22, 2022 9:52 pm

Trouble getting GPIO12 to go high

Thu Jan 26, 2023 7:35 pm

I'm trying to drive GPIO12 on a PI 2 Zero high but it's always low. I was able to control GPIO26 using pigpio in c++

gpioSetMode(26, PI_OUTPUT); // Set GPIO26 as output.
gpioWrite(26, 1); // Set GPIO26 high.

But when I try
gpioSetMode(12, PI_OUTPUT); // Set GPIO12 as output.
gpioWrite(12, 1); // Set GPIO12 high.

It always stays low. I'm looking at the header pin with a scope too.

I thought maybe I had the wrong fsel setting but it seems to match what I see for gpio26. But even here you can see the level always stays low for some reason.

The output of raspio get 12 is:
GPIO 12: level=0 fsel=1 func=OUTPUT

Where as the output of raspio get 26 is:
GPIO 26: level=1 fsel=1 func=OUTPUT

Am I missing something? Maybe because this is a PWM pin I have to treat it differently? Or maybe I have to set the function select for this pin somewhere else like a device overlay or something?

Any advice is appreciated.

Thank you

cleverca22
Posts: 7176
Joined: Sat Aug 18, 2012 2:33 pm

Re: Trouble getting GPIO12 to go high

Thu Jan 26, 2023 7:48 pm

esteimle wrote:
Thu Jan 26, 2023 7:35 pm
Am I missing something? Maybe because this is a PWM pin I have to treat it differently?
if it was in pwm mode, then the fsel from "raspio get 12" would have said so

how are you connecting to that pin? do you have photos?

User avatar
B.Goode
Posts: 14738
Joined: Mon Sep 01, 2014 4:03 pm
Location: UK

Re: Trouble getting GPIO12 to go high

Thu Jan 26, 2023 9:56 pm

esteimle wrote:
Thu Jan 26, 2023 7:35 pm
I'm trying to drive GPIO12 on a PI 2 Zero high but it's always low. I was able to control GPIO26 using pigpio in c++

[ ... ]

Any advice is appreciated.



Have you tried replicating the issue using the pigs CLI interface to the pigpio daemon?

https://abyz.me.uk/rpi/pigpio/pigs.html

User avatar
DougieLawson
Posts: 42395
Joined: Sun Jun 16, 2013 11:19 pm
Location: A small cave in deepest darkest Basingstoke, UK

Re: Trouble getting GPIO12 to go high

Thu Jan 26, 2023 10:04 pm

Languages using left-hand whitespace for syntax are ridiculous

DMs sent on https://twitter.com/DougieLawson or LinkedIn will be answered next month.
Fake doctors - are all on my foes list.

The use of crystal balls and mind reading is prohibited.

User avatar
thagrol
Posts: 8912
Joined: Fri Jan 13, 2012 4:41 pm
Location: Darkest Somerset, UK

Re: Trouble getting GPIO12 to go high

Thu Jan 26, 2023 11:52 pm

Which pin numbering scheme are you using? The broadcom GPIO ID, the physical pin number, wiringpi? It will make a difference.
Knowledge, skills, & experience have value. If you expect to profit from someone's you should expect to pay for them.

All advice given is based on my experience. it worked for me, it may not work for you.
Need help? https://github.com/thagrol/Guides

esteimle
Posts: 10
Joined: Tue Nov 22, 2022 9:52 pm

Re: Trouble getting GPIO12 to go high

Fri Jan 27, 2023 1:24 am

Thanks for all the replies. I'm probing with an oscilloscope probe right here: https://pinout.xyz/pinout/pin32_gpio12 The probe ground is connected to ground.

When I do this with GPIO_26 everything works fine.

I did not try pigs, but I'm not using the dameon approach. I'm just controlling it directly from my application.

User avatar
rpdom
Posts: 21544
Joined: Sun May 06, 2012 5:17 am
Location: Chelmsford, Essex, UK

Re: Trouble getting GPIO12 to go high

Fri Jan 27, 2023 9:17 am

I'm wondering if your code is clearing the level somewhere, or doing some sort of gpio cleanup.

If you set the level from the command line with raspi-gpio, what does it show?

This is what I get on a Zero 2W with Raspi OS Bullseye Lite 32-bit with 64-bit kernel

Code: Select all

notpi@cam2:~ $ raspi-gpio get 12
GPIO 12: level=0 fsel=0 func=INPUT
notpi@cam2:~ $ raspi-gpio set 12 op dh
notpi@cam2:~ $ raspi-gpio get 12
GPIO 12: level=1 fsel=1 func=OUTPUT
and test the level of the pin output.
Unreadable squiggle

User avatar
B.Goode
Posts: 14738
Joined: Mon Sep 01, 2014 4:03 pm
Location: UK

Re: Trouble getting GPIO12 to go high

Fri Jan 27, 2023 10:20 am

esteimle wrote:
Fri Jan 27, 2023 1:24 am

I did not try pigs, but I'm not using the dameon approach. I'm just controlling it directly from my application.


My suggestion was based on the idea that by using pigs or the supplied gpiotest utility you would be checking @joan's pigpio implementation and your own GPIO hardware independently of your own application code.

aBUGSworstnightmare
Posts: 7065
Joined: Tue Jun 30, 2015 1:35 pm

Re: Trouble getting GPIO12 to go high

Fri Jan 27, 2023 12:17 pm

another idea is using config.txt.
As OP states he/she has checked GPIO26 I've added it to the test scheme as well

# configure selected pin to output, set LOW
#gpio=xx=op,dl
# configure selected pin to output, set HIGH
#gpio=xx=op,dh

So for GPIO12=LOW and GPIO26=HIGH add below to your config.txt and reboot. Then measure the result or use 'raspi-gpio get' to see which level they have

Code: Select all

# configure selected pin to output, set LOW
#gpio=12=op,dl
# configure selected pin to output, set HIGH
#gpio=26=op,dh
now crosscheck them configured the other way around by changing config.txt to belo and reboot. Reheck the result.

Code: Select all

# configure selected pin to output, set LOW
#gpio=26=op,dl
# configure selected pin to output, set HIGH
#gpio=12=op,dh
Report back

Return to “Beginners”