Wednesday, 2 August 2017

stm32 - STM32F4 USART Receiver Pin Configuring


I am trying to configure STM32F4 USART peripheral. I thought that USART Receiver pin(RX) must be programmed as Alternate function to USART works correctly and then the data is present on the I/O pin can moves into the USART Receiver Shift register.



I mean that according to the following pictures taken from the STM32F4 Reference manual, when we do configure a pin as Alternate function it gives a way for the data to moves into the Alternate function input(here it is Receiver shift register) but when that pin is configured as Floating input (second picture) the data on that pin is just sampled into the input data register.


enter image description here


enter image description here


So logically i think that USART can't do it's job correctly when Receiver pin is configured as Floating input. but incredibly it does work in a correct way and i dont know why?!


The same Problem has been discussed here : Why is the USART receiver pin configured as “input floating”?


But i couldn't find my answer there.


Edited:


Ambiguous point is that however in Floating input mode the data will also be sent to the connected Alternate functions But it's important to specify which peripheral this data will be sent to.


When the microcontroller starts up from Reset mode, Reset values of almost all Registers is 0 so for instance pin 7 by default is connected to AF0 which that isn't for USART periph. So if we select Floating input mode for that pin and don't determine which alternate function we want to send the data, then the data might be sent to the wrong peripheral instead of USART receiver shift register.


But incredibly without determining the peripheral which we want to select as our Alternate function, USART does the work correctly. Actually my question is WHY does USART work correctly in this way (without determining The actual Alternate function)?




Answer



Well, I'd say the basic structure picture tells you why this might work:


Basic structure of a five volt tolerant I/O port bit


There is no block which would allow the selection of the digital input only going to the input data register or the alternate function input. So a pin configured as digital input will also send the data to the connected alternate functions.


The only option there is to have the schmitt trigger on or off, but that turns off the whole digital and alternate input then.


I'd still use the alternate function setting, because that is the intended way to use it and as long as no official source tells us otherwise I'd stick to what the manufacturer says (well except it doesn't work and you work out a workaround).


No comments:

Post a Comment

arduino - Can I use TI's cc2541 BLE as micro controller to perform operations/ processing instead of ATmega328P AU to save cost?

I am using arduino pro mini (which contains Atmega328p AU ) along with cc2541(HM-10) to process and transfer data over BLE to smartphone. I...