Community migration in progress. Please bear with us as we work through the migration.

Up Squared GPIO stuck on high signal? GPIO pins not working correctly?

Bart van OortBart van Oort Posts: 6New Member

Hi,

I'm currently trying to control some LED strips with my Up Squared (N4200), but I cannot seem to get them working. After a lot of debugging to get to the root of the problem, I found out that the GPIO pins may be malfunctioning.

My Up Squared is running Ubuntu 16.04, my BIOS version is 1.8 and the output of uname -srv is:
Linux 4.10.0-42-generic #5000~upboard10-Ubuntu SMP Tue Dec 19 12:58:48 UTC 2017

I have a 9 jumper cables connected to (what I think are) pins 3, 5, 7, 11, 13, 15, 19, 21, and 23 as shown in the picture below. Due to debugging, none of these cables were actually attached to anything.

Using the mraa library, I was trying to execute the following code:

import mraa
import time

redPin = mraa.Gpio(19)
time.sleep(0.1)
redPin.dir(mraa.DIR_OUT)

while True:
    print("On")
    redPin.write(1)
    redPin.dir(mraa.DIR_IN)
    print("Should be 1:", redPin.read())
    redPin.dir(mraa.DIR_OUT)
    time.sleep(2)
    print("Off")
    redPin.write(0)
    redPin.dir(mraa.DIR_IN)
    print("Should be 0:", redPin.read())
    redPin.dir(mraa.DIR_OUT)
    time.sleep(2)

When I execute this code as root, I get the following output:

On
('Should be 1:', 1)
Off
('Should be 0:', 1)
On
('Should be 1:', 1)
Off
('Should be 0:', 1)
On
('Should be 1:', 1)
Off
('Should be 0:', 1)

(and so on..)

Keep in mind that the specific cable was not attached to anything. I currently don't have access to a multimeter, so I can't really check if these readings are in accordance to what is actually emitted through the cable. However, when I attach this cable to the according MOSFET in my LED powering circuitry (built following this tutorial, though with IRLB8721 MOSFETs), the LED strip does light up, but does not turn on and off like the code should make it do (or even slightly change brightness for that matter).

Seeing as I'm not inclined to believe that the printed output is expected behaviour, what could be wrong here? Might it be something in my BIOS settings (haven't checked those yet)? And / or should I update my BIOS? Am I using the wrong pins? Or is there something wrong with my Up Squared?

Comments

  • Javier ArteagaJavier Arteaga Posts: 152Emutex mod

    Hi Bart,

    Sorry we didn't get to you sooner. When you call redPin.dir(mraa.DIR_IN), you're actually changing the pin settings on both the SoC and FPGA to GPIO input mode. When the pin is in input mode and left floating, you're not guaranteed to get a meaningful value (and not necessarily even the value that was last set).

    You can just remove the .dir(...) calls and still get the current pin state with .read() even if the pin is set as an output.

Sign In or Register to comment.