This is an automated email from the ASF dual-hosted git repository. xiaoxiang781216 pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/nuttx.git
commit dea993847ab72c7b1aab340f4d994ceac2ccaa7f Author: Kerogit <[email protected]> AuthorDate: Tue Mar 31 10:48:17 2026 +0200 arch/avr/src/avrdx/avrdx_lowconsole: fix zero pulse in UART activation UART peripheral activation procedure listed in AVR128DA28 datasheet changes the TXD pin to output and then activates the peripheral. This leads to a short logical 0 pulse that can be interpreted as a START bit by the receiving side. This patch adds an intermediate step and sets the TXD pin to logical 1 before switching it to output, removing the pulse. Signed-off-by: Kerogit <[email protected]> --- arch/avr/src/avrdx/avrdx_lowconsole.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/arch/avr/src/avrdx/avrdx_lowconsole.c b/arch/avr/src/avrdx/avrdx_lowconsole.c index 65e0d3707a9..b95bd49e88e 100644 --- a/arch/avr/src/avrdx/avrdx_lowconsole.c +++ b/arch/avr/src/avrdx/avrdx_lowconsole.c @@ -374,6 +374,8 @@ void avrdx_usart_reset(struct avrdx_uart_priv_s *priv) AVRDX_USART_PORT(priv->usart_n).DIRCLR = \ avrdx_usart_tx_pins[priv->usart_n]; + AVRDX_USART_PORT(priv->usart_n).OUTCLR = \ + avrdx_usart_tx_pins[priv->usart_n]; usart->CTRLA = 0; usart->CTRLB = 0; @@ -500,6 +502,19 @@ void avrdx_usart_configure(struct avrdx_uart_priv_s *priv) ) | \ avrdx_usart_portmux_bits[priv->usart_n]; + /* AVR128DA28/32/48/64 datasheet rev C, section 25.3.1 lists changing + * the pin direction before activating the device itself but that + * leads to short zero pulse. No problems were observed doing it like + * that - but that was only with PC on the other side of the connection + * and the receiver may be filtering the pulse out (if it even reaches + * the other side of the cable.) + * + * Nevertheless, we add additional step that sets the output value + * to UART idle level before switching the pin to output. + */ + + AVRDX_USART_PORT(priv->usart_n).OUTSET = \ + avrdx_usart_tx_pins[priv->usart_n]; AVRDX_USART_PORT(priv->usart_n).DIRSET = \ avrdx_usart_tx_pins[priv->usart_n];
