Skip to main content
EAlek.2
Associate
September 7, 2021
Question

How reinit UART?

  • September 7, 2021
  • 3 replies
  • 3362 views
  1. After reset MCU init UART - 8bits, no parity bit, init DMA RX and TX, interrupts on - works Ok.
  2. Reinit UART - 9 bits, even parity bit, no DMA - works Ok.
  3. Reinit UART the same as p.1 - doesn't work interrupts.
This topic has been closed for replies.

3 replies

TDK
September 7, 2021

Before reinitializing, reset the peripheral with the RCC force/release reset bits to get it back to the as-reset configuration.

__HAL_RCC_USART1_CLK_ENABLE();
__HAL_RCC_USART1_FORCE_RESET();
__HAL_RCC_USART1_RELEASE_RESET();

The initialization is likely expecting this to be as-reset.

"If you feel a post has answered your question, please click ""Accept as Solution""."
Tesla DeLorean
Guru
September 7, 2021

DMA would need to be 16-bit for the 9-bit mode.

Perhaps you could double check the content of the DMA controller registers, and share those. If this is a bug it could probably be added to the list.

Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..
waclawek.jan
Super User
September 7, 2021

> doesn't work interrupts

Which interrupts? How do you know they don't work?

Debug as usually: read out and check relevant UART, DMA, NVIC registers.

JW