I'd like to share my experience and code for using the unused pins on Portenta H7 MCU module as digital GPIO pins (input, output, open-drain, not as EXTI yet).
You will see (as I did) signals called PA0_C, PA1_C, PC2_C and PC3_C (on MCU module header J2).
How to configure such PA0_C. And what does it mean, this _C?
OK, I got it, based on this:
STM32H7xx GPIOs
There are pins for PA0 as well as PA0_C. If available depends on the chip (e.g. BGA package). We have it this way on Portenta H7 (the biggest package used with all the pins).
But just using PA0 (instead of PA0_C, which is physically a different ball/pin) will not work.
_C is a direct analog input pin. It can be switched (internal analog switch) in order to be connected with the other pins (here PA0_C can be analog switched with PA0, and you configure and drive PA0 but it comes out on PA0_C).
So, you had to do something like this:
HAL_SYSCFG_AnalogSwitchConfig(SYSCFG_SWITCH_PA0, SYSCFG_SWITCH_PA0_CLOSE);
OK, it works. Attached my GPIO_usr files:
GPIO_usr.h (1.1 KB)
GPIO_usr.cpp (4.8 KB)
Strange is just PA1_C:
it shows me a low voltage of approx. 326mv (much higher as the others when set to low) and 3.08V (lower as the others with 3.1V as driving high).
Is this signal connected to something else on the board?
I use the breakout board. Maybe, it is intended to monitor battery voltage, it is connected to battery charger... Why the voltage there is different as the other GPIOs? (still to TODO a schematics check if signal goes to something else)
Dear community, potentially you can teach me:
mbed uses actually different methods to configure GPIOs. I see pins as numbers, e.g. 166 for green LED (instead of GPIOx, GPIO_PIN_y, as I use via STM HAL).
-
Where could I find the GPIO pin definition (pin numbering) for mbed and this board?
-
Is the name in schematics for Portenta H7 MCU module, e.g. as J2-75 (as for PA1_C), a hint that it is pin number 75 in mbed software?
-
When it comes to PA1_C pin - can I configure as GPIO input and output and does it do this analog switch configuration for me?
(Otherwise it would not come out when just PA1 is configured, as I understand it has to be "cross-connected" with other ball/pin PA1_C via analog switch.)
BTW: VDD_IO is just 3.1V - not 3.3V
When you see schematics or you measure voltage on pull-ups, GPIOs driven high - the voltage on board is just 3.1V, not 3.3V. So, all the IO voltages are just 3.1V.
OK, just a smaller noise margin for digital signals. But potentially you had to be careful when you connect Portenta H7 to another external HW which is running with 3.3V. Pins should be 5V tolerant when used as input. But if you have a higher load on GPIO output pins - the high voltage level on external HW can be seen a bit lower, resulting in a threshold issue to realize a high level.
(why board runs just with 3.1V? For power saving reasons? OK, the PMIC involved: does it need this drop for a stable voltage out?)