2022-07-05 12:54 AM
In my STM32, if I have set the GPIO_MODER as "Alternate function" and did not set any values in the GPIO_AFRL and GPIO_AFHL, I guess it will take the defaukt value of AF0. What is AF0 used for ?
2022-07-05 01:32 AM
"What is AF0 used for ?"
The datasheet will tell you that; eg,
2022-07-05 02:18 AM
Thanks for the prompt response. I am trying to debug a failure scenario. PA5 is what is the GPIO pin used ? As per the reference manual, AF0 for this pin does not have any function. obviously, this is a misconfiguration ? My specific question is that if there is such a configuratuion, what will this GPIO pin output ? Will it be random ? or will it default to 1 or 0 ?
2022-07-05 02:56 AM
You haven't said what part you're using.
2022-07-05 02:56 AM
Which STM32?
> I guess it will take the default value of AF0
You don't need to guess, the GPIO_AFR registers description in RM tells you exactly what the default values are.
> My specific question is that if there is such a configuratuion
> [for given pinm, MODER set to AF, AFR set to AF0, and there's no function assigned to AF0 in the datasheet],
> what will this GPIO pin output ? Will it be random ? or will it default to 1 or 0 ?
It is unspecified, i.e. the datasheet/reference manual won't tell you what will it do.
However, it is not likely to be entirely random. I have made that configuration mistake in the past, and my experience was, that the pin took the function of other AF defined for that pin. As pins set to AF in MODER are controlled by the assigned peripheral, this means, that the pin could behave as input or as output, set to either level or toggling (in my case, I was expecting that the pin will be set as input but given incorrect AF, it was set to ouput and . This of course means nothing, your chip may behave entirely differently.
JW
2022-07-05 11:47 PM
STM32L151VE