2019-09-03 04:37 AM
For example, if two pins are set, via the Alternative Function registers, to be the rx and tx for a UART, but that UART is disabled, what state are the pins left in if the various GPIO registers are not changed?
Does the rx pin remain an input, and the tx an output? Does the tx level stay at its previous value, or does it revert to whatever is in the corresponding bit of its GPIO output register?
(As far as I can tell, the STM32L4 reference manual is silent on this, and I've been unable to find any definitive answer. The closest is this question, though it doesn't address this specific question.)
2019-09-03 06:42 AM
I don't think you will find a definitive answer in the RM or other materials, but it appears that the peripherals (IPs) follow a pattern: inputs are not interesting, they are the same as digital inputs (i.e. Schmitt trigger connected); at outputs (more precisely, pins, where the IP controls the output enable of given pin, and sets output enable active when appropriate, in case of UART Tx it's always), the output enable goes inactive as soon as the IP is disabled, so it again behaves as digital input.
There may be exceptions and surprises (see e.g. my finding reported in that thread regarding a undefined AF for a given pin turning it to output, even if this is not directly related to this question), so if you want to rely on this you should ask ST directly.
JW
2019-09-03 07:16 AM
Thanks for the response.
Unless it turns that there is a definitive answer, I'm inclined not to rely on any inferred behaviour, and instead manually switch the pins to inputs or outputs when we disable the peripheral.