New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
stm32/uart: remove pullup resistor from UART pins. #4369
stm32/uart: remove pullup resistor from UART pins. #4369
Conversation
The internal Pullup resistor can be enabled when needed.
-1 The default state of a UART input is high. If it were left to float an unconnected UART Rxd line would be likely to pick up meaningless data. What is the objection to the high-value pullup? |
Seems like an idea that needs explaining: having the pin floating by default (when not connected). Better to disable it when the port pin is used for something else or when you are sure it is connected to a push/pull output. |
On an Embedded system the USART RX pin is usually connected to the TX pin of another device, Because of the way the pullup is enabled when initializing the UART it is also not possible to disable the pullup in python. |
I am puzzled by this statement. The internal pullup is on the order of 47KΩ. There will only be a problem with the 0V level if the pin is driven from a high impedance source (which is never ideal). Perhaps you can explain your use case? I've used the UARTs extensively without issue. One concern is that a naive user might implement an output-only application leaving the input pin floating, and be confused by reams of spurious input. |
What I understand from @peterzuger's statement is, that he thinks about a resistor between an board pin and the MCU's UART RX, which limits the inrush current in case of voltage spikes. That resistor indeed creates a voltage divider in combination with the pull-up resistor in the MCU, and has effect on the low input level that can be achieved. |
The UART Rx has to have the pullup so that spurious data isn't generated when nothing else is driving the line. Without the pullup, the line will have a tendency to capacitively couple with nearby traces on the circuit board and will tend to follow that nearby trace (CMOS is especially susceptible to this). This can cause excessive power consumption and lots of junk on the Rx line (especially if the trace is near a high frequency clock). The pullup is only enabled if the UART is actually initialized. If you want to use the pin for something else and not have the pullup, then don't initialize the UART. The only UARTs that are initialized by default are the ones on the boards where there is a secondary processor providing STLINK debugging and USB-to-serial translation. |
If he's putting such a resistor in place whose value is so high that it's causing this problem I would argue that this is poor design. Pins should be driven from low impedance sources to avoid picking up capacitive noise as @dhylands has pointed out. If a UART is to be used with long lines where spikes are a serious concern, proper RS232 or RS422 line drivers should be used. Such chips are designed to cope, and will drive the MCU pin from a low impedance output. |
perhaps a bit off topic.. but serie R‘s are beneficial for example against transient bursts, e.g. ESD etc. low impedance usually doesnt help in that case since they cant get rid of the energy spike that is being forced into the pin. A simple resistor is then used to clamp the inrush current spike to an accetable level. But there is a tradeoff between this use case and the normal case where properly, low impedance driven data lines are better. My experience is that several 100s of ohms should be a fair balance between these two cases. and with these values, its not a problem with the 47k pullup. |
As @robert-hh guessed, the problem I have is that the series resistor on the MCU Pin is preventing the UART from receiving data. |
Having the pull up on the RX pin is, IMO, a useful default. It's possible to turn off the pull up from Python, eg: uart = machine.UART("XA", 115200)
machine.Pin("X2", machine.Pin.ALT, alt=machine.Pin.AF8_UART4) So I'll close this PR in favour of that code snippet.
Yes agreed! |
RX and CTS are the input pins and pull-ups are enabled so they don't cause a problem if left unconnected. If needed, the pull-ups can be disabled in Python using machine.Pin after the UART is constructed. See issue micropython#4369. Signed-off-by: Damien George <damien@micropython.org>
See #7277. |
RX and CTS are the input pins and pull-ups are enabled so they don't cause a problem if left unconnected. But the output pins don't need a pull up (they were originally all configured with pull up in commit 8f7491a). If needed, the pull-ups can be disabled in Python using machine.Pin after the UART is constructed. See issue micropython#4369. Signed-off-by: Damien George <damien@micropython.org>
RX and CTS are the input pins and pull-ups are enabled so they don't cause a problem if left unconnected. But the output pins don't need a pull up (they were originally all configured with pull up in commit 8f7491a). If needed, the pull-ups can be disabled in Python using machine.Pin after the UART is constructed. See issue micropython#4369. Signed-off-by: Damien George <damien@micropython.org>
RX and CTS are the input pins and pull-ups are enabled so they don't cause a problem if left unconnected. But the output pins don't need a pull up (they were originally all configured with pull up in commit 8f7491a). If needed, the pull-ups can be disabled in Python using machine.Pin after the UART is constructed. See issue micropython#4369. Signed-off-by: Damien George <damien@micropython.org>
The internal Pullup resistor can be enabled when needed.