GPIO pins use retained by prior program

CircuitPython on hardware including Adafruit's boards, and CircuitPython libraries using Blinka on host computers.

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
theboatbuilder59
 
Posts: 7
Joined: Sat Feb 01, 2020 6:43 pm

GPIO pins use retained by prior program

Post by theboatbuilder59 »

My project uses a Pimoroni tiny 2040 to drive a GC9A01 display as a clock replacing a broken mechanical clock in my old car.
It works fine. No errors.
However, I removed the tiny 2040 I used on the project development strip board to repurpose it.
I wanted to check I hadn't damaged it through desoldering.
I wrote a simple program to alternate the GPIO pins from low to high every 2 seconds so I could check their state.

Trying to load the program using Mu I got the error that GP2 is already in use. I comment out those lines and I get GP3 in use.
In summary GP2 to GP7 error as 'in use'. These are the pins I drive the GC9A01 with....

So I flash the tiny 2040 with the flash_nuke.uf2
Then re-flash with adafruit-circuitpython-pimoroni_tiny2040-en_US-7.1.1.uf2
Reload the pin test code and it works fine.

I did the whole process again reloading the clock software followed by the pin test software and the problem persists. GP2-GP7 in use,

Then I introduced the following line of code taken from the clock program into the pin test code.

displayio.release_displays()

This problem of 'retained GPIO use' disappears.

Ok. Its a hack.
Is there a better way of preventing/fixing the 'retained GPIO use' problem I've run into?
Why does it remember previous program assignments?
Clearly I'm doing something wrong.

Many thanks in advance.

User avatar
tannewt
 
Posts: 3304
Joined: Thu Oct 06, 2016 8:48 pm

Re: GPIO pins use retained by prior program

Post by tannewt »

This is due to displays working after the user code finishes. We do this so that error text appears on the display.

It leads to this weirdness where display pins aren't automatically reset like others. `displayio.release_displays()` is the correct way to work around this because we needed an explicit point to turn off the display.

Locked
Please be positive and constructive with your questions and comments.

Return to “Adafruit CircuitPython”