From f62bfca94eb23ff527e2c9cbfcfcd1c0ba4e4dca Mon Sep 17 00:00:00 2001 From: Simon Piriou Date: Mon, 12 Mar 2018 22:01:00 +0000 Subject: [PATCH] Merged in spiriou/nuttx/stm32_lowputc (pull request #613) arch/arm/src/stm32/lowputc: fix uart glitch when lowputc is enabled Calling up_lowputc() when a character is in the shift register results in corrupted character on stm32f1xx and stm32f205 cores. TC status bit ensures that up_lowputc() waits for an on-going transmission to complete before writing in TDR. Approved-by: Gregory Nutt --- arch/arm/src/stm32/stm32_lowputc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/arm/src/stm32/stm32_lowputc.c b/arch/arm/src/stm32/stm32_lowputc.c index 63e7090434..3c87b6e986 100644 --- a/arch/arm/src/stm32/stm32_lowputc.c +++ b/arch/arm/src/stm32/stm32_lowputc.c @@ -413,7 +413,7 @@ void up_lowputc(char ch) #ifdef HAVE_CONSOLE /* Wait until the TX data register is empty */ - while ((getreg32(STM32_CONSOLE_BASE + STM32_USART_SR_OFFSET) & USART_SR_TXE) == 0); + while ((getreg32(STM32_CONSOLE_BASE + STM32_USART_SR_OFFSET) & USART_SR_TC) == 0); #ifdef STM32_CONSOLE_RS485_DIR stm32_gpiowrite(STM32_CONSOLE_RS485_DIR, STM32_CONSOLE_RS485_DIR_POLARITY); #endif