December 29, 2025

Kyu - H5 - blink the red status LED

I can blink the green "power" LED, but not the red "status" LED.

These LED are connected as follows:

Red "status" LED on PA15
Green "power" LED on PL10
The red LED should be easy given that it is connected to the first GPIO and should not have any quirks.

The usual problem I have with Allwinner peripherals not working is that each peripheral has its own clock and reset control and the board comes up with the clock off and the device held in reset.

A quick peek yields no solution. There seems to be no reset bit allocated for the GPIO. There is one "PIO" clock control bit. This effort starts to turn into several small projects:

The Allwinner H5 manual

You don't find "GPIO" anywhere. You do find PIO in section 4.1 which is the memory map. Surely they document this somewhere. And they do! They call these "Port controllers" and they are described in section 4.21 of the TRM.

As well as the PIO, we want documentation for the pin mux. This is handled by the first 4 registers in the GPIO itself. Each register has 8 fields, 4 bits in size, so the 4 registers can configure 32 pins. All this is described under "Port Controller". Only 3 bits of the 4 are actually used.
A value of 0 selects GPIO input
A value of 1 selects GPIO output
The other 6 values can select alternate functions

I was eager to check that the port function mux was set up so the pin in question would actually drive the output. And it was and is.

The connector pinout

The 40 pin connector is identical to the one on the H3 boards!
How nice!

Experiments

I decide to try some things. I want to use my oscilloscope to see if I can drive waveforms on some of the IO pins to see if other pins on GPIO-A work, or on GPIO-B or C. The idea being to see if all of the GPIO are non-functional or what is going on.

I write some code to write to all 32 bits in the GPIO-A data register (after configuring them all to outputs. A broad brush approach. I hit paydirt more quickly than I dreamed as the red LED comes on! I am sending a 100 Hz square wave on all pins, so no doubt it is not full brightness, but this is exciting.

Now it is a trial and error process of finding out which bit is controlling the LED. It turns out to be this bit:

0x00100000
By my reckoning, this is bit 20. And indeed, when I specify A20 for the status LED, my regular code blinks it nicely.

And the schematic shows PA20 as clear as can be as being the STATUS LED, so where did I get the idea it was A15? Was I so foolish as to assume it would just be the same as the H3 boards? Maybe so.

Conclusion

Along the way I began telling myself, "check the obvious and basic stuff". I never guessed it would be so basic as having the wrong GPIO signal, but that is what it turned out to be.

Something to keep in mind for the future.


Have any comments? Questions? Drop me a line!

Tom's electronics pages / tom@mmto.org