mogo4414
Posts: 56
Joined: Fri Mar 27, 2020 1:10 am

Using all GPIO pins as general purpose GPIO

Tue Aug 11, 2020 3:31 am

Hello,

I am working on a project that will required either 18 or 24 GPIO pins. 2/3's of the pins will require the internal pull/up resistor and the other 1/3 will control stepper motors through PUL/DIR.

My question is, despite there being 26 GPIO pins, only 17 are designated as general GPIO, so if I do not enable the SPI/I2C/etc, can all 26 GPIO pins be used reliably, long term, as general function GPIO pins?

I am happy to go through each and test, but I feel like the issue is a bit more complicated and could lead to failures, that might not be immediately obvious.

I guess I am just hoping for some guiding comments: not possible/possible but hard/possible and easy/just use no change necessary/etc.

Thank you in advance for your time and help.

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

Re: Using all GPIO pins as general purpose GPIO

Tue Aug 11, 2020 5:18 am

Yes, should be fine.

Things to watch for are:

* Default pull states on boot

* Default functions like UART output from the boot loader

* Hard-wired 1K8 pull-ups on GPIO 2 & 3

* Any enabled interfaces, like 1-wre on GPIO 4, for example

Will any of these things cause undesirable behaviour in your hardware?

Alternatively you can use i2c GPIO expanders to drive many more outputs/inputs.
Unreadable squiggle

LTolledo
Posts: 3585
Joined: Sat Mar 17, 2018 7:29 am
Location: Anime Heartland

Re: Using all GPIO pins as general purpose GPIO

Tue Aug 11, 2020 9:37 am

rpdom wrote:
Tue Aug 11, 2020 5:18 am
Alternatively you can use i2c GPIO expanders to drive many more outputs/inputs.
+1 on this

1 GPIO extender for inputs
1 GPIO extender for outputs

the GPIO extenders will bear the brunt of possible mistakes.... and protect your RPi
"Don't come to me with 'issues' for I don't know how to deal with those
Come to me with 'problems' and I'll help you find solutions"

Some people be like:
"Help me! Am drowning! But dont you dare touch me nor come near me!"

User avatar
Imperf3kt
Posts: 3674
Joined: Tue Jun 20, 2017 12:16 am
Location: Australia

Re: Using all GPIO pins as general purpose GPIO

Wed Aug 12, 2020 1:07 am

Don't forget the current limits also.
16mA on any single GPIO, 50mA across all GPIO combined.
55:55:44:44:4C
52:4C:52:42:41

mogo4414
Posts: 56
Joined: Fri Mar 27, 2020 1:10 am

Re: Using all GPIO pins as general purpose GPIO

Wed Aug 12, 2020 1:43 am

Thank you all that was very informative!

rpdom,

I'm not sure specifcally if any of those mentioned points will be an issue, so hopefully all is alright. And as for I2C, I am planning to switch over shortly, still watching some tutorials on it at the moment.

Imperf3kt,

I'm only going to be using the internal pull-up resistor over short distance and PUL/DIR signaling from a stepper motor driver. I'm not sure what the current draw is exactly but I don't think this will reach 50mA?

Return to “Beginners”