cancel
Showing results for 
Search instead for 
Did you mean: 

Alternate Function 0 in STM32

SNara.6
Associate II

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 ?

5 REPLIES 5

"What is AF0 used for ?"

The datasheet will tell you that; eg,

0693W00000QKRrQQAX.png

SNara.6
Associate II

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 ?

You haven't said what part you're using.

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

STM32L151VE