GPIO 20 and 21 not working

markus.vocore
 
Posts: 10
Joined: Thu Mar 22, 2018 2:46 pm

GPIO 20 and 21 not working

Thu Mar 22, 2018 3:01 pm

Hello everybody,

I just started working with VoCore2 and I really like it. I would like to use GPIO 19, 20, 21 and GPIO 39, 40 and 41 as Output. Most of the mentioned GPIOs are working fine, but not GPIO 20 (Output is always high, +3,3V) and not GPIO 21 (Output is always +0.5V).

I tried different VoCore2 because my first guess was that the GPIOs are defect. But it's always the same behavior.

What am I doing wrong? I guess the GPIOs are still configured as PWM Output, am I right? Please find the test script and and the terminal output below.

Many thanks in advance and kind regards,
Markus


Code: Select all
#!/bin/bash

echo 19 > /sys/class/gpio/export
echo 20 > /sys/class/gpio/export
echo 21 > /sys/class/gpio/export
echo 39 > /sys/class/gpio/export
echo 40 > /sys/class/gpio/export
echo 41 > /sys/class/gpio/export
echo out > /sys/class/gpio/gpio19/direction
echo out > /sys/class/gpio/gpio20/direction
echo out > /sys/class/gpio/gpio21/direction
echo out > /sys/class/gpio/gpio39/direction
echo out > /sys/class/gpio/gpio40/direction
echo out > /sys/class/gpio/gpio41/direction
echo "..."
cat /sys/kernel/debug/gpio
echo "..."

while true; do
echo 0 > /sys/class/gpio/gpio19/value
echo 0 > /sys/class/gpio/gpio20/value
echo 0 > /sys/class/gpio/gpio21/value

echo 1 > /sys/class/gpio/gpio39/value
echo 0 > /sys/class/gpio/gpio40/value
echo 0 > /sys/class/gpio/gpio41/value
sleep 2

echo 0 > /sys/class/gpio/gpio39/value
echo 1 > /sys/class/gpio/gpio40/value
echo 0 > /sys/class/gpio/gpio41/value
sleep 2

echo 0 > /sys/class/gpio/gpio39/value
echo 0 > /sys/class/gpio/gpio40/value
echo 1 > /sys/class/gpio/gpio41/value

echo 1 > /sys/class/gpio/gpio19/value
echo 1 > /sys/class/gpio/gpio20/value
echo 1 > /sys/class/gpio/gpio21/value
sleep 2

done


root@OpenWrt:~# /bin/ash /noser/gpio_testscript.sh
...
GPIOs 0-31, platform/10000600.gpio, 10000600.gpio:
gpio-4 (scl ) in hi
gpio-5 (sda ) in hi
gpio-19 (sysfs ) out lo
gpio-20 (sysfs ) out lo
gpio-21 (sysfs ) out lo
GPIOs 32-63, platform/10000600.gpio, 10000600.gpio:
gpio-39 (sysfs ) out lo
gpio-40 (sysfs ) out lo
gpio-41 (sysfs ) out lo
GPIOs 64-95, platform/10000600.gpio, 10000600.gpio:
...

Vonger
 
Posts: 896
Joined: Sun Oct 19, 2014 6:00 am

Re: GPIO 20 and 21 not working

Fri Mar 23, 2018 4:24 pm

Please check mt7628 datasheet, if you want to use GPIO first make sure its pinmux switch to GPIO(or they will be use as other function such as i2c i2s, spi etc...), then you can export and use it.

markus.vocore
 
Posts: 10
Joined: Thu Mar 22, 2018 2:46 pm

Re: GPIO 20 and 21 not working

Thu Mar 29, 2018 11:02 am

Dear Vonger,

You are right, it was because of the default configuration of the multipurpose I/O.

For everybody struggling with the same issue, see MT7628 datasheet. The I/O pins P2TP (MDI_TP_P2) and P2TN (MDI_TN_P2) can be configured with the following I/O functions:
- MDI_TP_P2: UART2 (TxD), GPIO20, PWM (CH2), SD-Card D5
- MDI_TN_P2: UART2 (RxD), GPIO21, PWM (CH3), SD-Card D4

By default, the pins are set as UART2. To use GPIO20 and GPIO21, the GPIO1_MODE (address 0x10000060) must be set as following:
- Bits 27/26: 0x01 (GPIO)
- Bits 11:10: 0x01 (GPIO)

In my case, the default value of Register GPIO1_MODE was set to 0x5015040E (command "mem 0x10000060) and I had to set it to 0x5415040E (command "mem 0x10000060 0x5415040E").

Best regards,
Markus

rezajahadi
 
Posts: 1
Joined: Mon Nov 28, 2022 10:12 am

Re: GPIO 20 and 21 not working

Mon Nov 28, 2022 10:17 am

Hello markus.vocore,

Could you please explain the way of enabling gpio 20 & 21 again?
I didn't understand well as there is no command called "mem 0x10000060 0x5415040E" to write in registers.

Thank you in advance,

im_chc
 
Posts: 4
Joined: Wed Nov 23, 2022 2:10 am

Re: GPIO 20 and 21 not working

Wed Dec 07, 2022 9:05 am

To download the mem tool, goto https://vocore.io/v2u.html, look at the bottom most section

Return to VoCore2/Lite/Ultimate

Who is online

Users browsing this forum: Google [Bot] and 53 guests