Showing results for 
Search instead for 
Did you mean: 

STM32L0xx - why is PA4 initialized as digital input?

In STM32L0xx, all pins are initialized as Analog, except PA13/PA14 which are SWDIO/SWCLK, initialized as AF; and PA4, which is initialized as [digital] Input.

I can't find any reason for the latter.

It's not that important, and I can simply take it as a fact - unless it hides some nasty surprise...

Any insight?


ST Employee

Well spotted, that is indeed an interesting question!

In fact, port A is only preset for the STM32L0 with GPIOx_MODER = 0xEBFF FCFF, i.e. PA4 = input. With the other STM32, either only the SWD pins or also the JTAG pins are initialized to AF, the rest either to digital input (older devices) or to analog (newer ones).

Maybe it's an Easter egg of one of the chip designers.😉

But it will probably be overwritten during initialization anyway, right?



In order to give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.

The 'L05x and 'L07x DS mention "decreased touch sensitivity" namely for PA4, so there will be some structural difference probably resulting in increased parasitic capacitance or leakage, too. Most probably an internally used, publicly undocumented feature.

> But it will probably be overwritten during initialization anyway, right?

Yes, if the program is written with this fact in mind. It just underlines the adage that documentation must be read and assumptions should not be made. At least for those who don't click in CubeMX... 😉