ARM: Read the value of an Alternate Function pin

armgpio

I have an ARM STM32 where each GPIO pin can be configured as "input", "output", "analogue" or "alternate function". In "alternate function" mode, the ARM drives a lot of the logic for basic communication protocols, removing some of the grunt work for the programmer.

While I have been able to "read" the value of input and output GPIO pins using the standard library functions GPIO_ReadInputDataBit and GPIO_ReadOutputDataBit, I cannot seem to be able to read the value of alternate function pins without using a scope.

Is there a way to query the ARM about the value of its alternate function pins?

Best Answer

Apparently not, and I haven't seen a microcontroller that could. When you assign the alternate function to the pin the signal is rerouted to that function's interface, away from the GPIO register. If you assign for instance the I2C function to a pair of pins the microcontroller will say that what happens at the pins is none of your business; you'll have to pass at the I2C controller.

It's obvious that the pin can't be used for output, because of the conflicts it would cause, but while the use as input is more harmless it seems to be pointless, since the I2C controller will give you everything you need.

Debugging is a possible purpose, but that's not the function of the microcontroller, that's what we have scopes and logic analyzers for.