cancel
Showing results for 
Search instead for 
Did you mean: 

Fastest way to configure many GPIO pins in CubeMX?

NathanL
Associate II

I feel like I'm missing something basic here. What is the fastest way to configure many pins for GPIO in CubeMX? I have over 100 pins I need to configure and the only way I know how is somewhat tedious.

For example, I need to make the entirety of PORT D, E, G, I, and J pins all GPIO_Output. The best way I've found is to use the search bar at the bottom of the Pinout view in CubeMX, search for PG0, then click on the pin in Pinout view, select GPIO_Output, then right-click on the same pin, select Enter User Label, and then type in my label.

Is there a way to just get an alphabetical list of all the pins, PA0, PA1, PA2, etc. so I can just multiple-select and configure entire groups as GPIO_Outputs at once? Pins will show up in the GPIO Mode and Configuration table, but only after they are configured, not before. I can't easily just work my way around the package in Pinout view because the pins are never physically in alphabetical order, so that would involve a lot of hunting for the right pin.

Ideally, I could do a CSV import but I don't think that's a feature that exists.

2 REPLIES 2
Pavel A.
Evangelist III

The GPIO info entered into the Cube and the .ioc file eventually gets converted to C code. Instead of mousing over the Cube, just write directly the GPIO configuration code, and it can be much better (simpler, smaller) than cube-generated. (if you already have the .csv file, consider a script or excel macro to convert that to C code).

(see also: the X/Y problem).

Thanks. I might have been being a bit stubborn in trying to avoid just entering it all manually into Cube. It didn't actually take all that long just by searching for a specific pin name, clicking to mark as GPIO_Output, and moving to the next one since they are usually at least located in small groups all in numeric order of the same port. Then I could just use the "Pinout > Pins/Signals Options" window to sort by pin name and assign them all my own custom name.

I know what you mean by doing things outside of Cube though. I mostly use Cube for initial setup and keeping track of what peripherals are in play, but then I use the registers directly when doing anything remotely complicated like combined regular/injected simultaneous ADC conversions.