cancel
Showing results for 
Search instead for 
Did you mean: 

HAL_UART_DeInit() behaves unexpectedly

ranran
Senior II

Hello,

I have several UARTs when initializing them all simply with HAL_UART_Init , each with its own UART_HandleTypeDef instance, than things works fine.

But on adding HAL_UART_DeInit before HAL_UART_Init (this is actually the generated code from stm32cube) , than the second UARTinit resulted in malfunction of the first UART.

I have verified that the instance of UART_HandleTypeDef is not the same.

Any idea why it behaves like this ?

Thanks,

ranran

3 REPLIES 3
e-zeki
Associate III

Things are a little bit foggy here. correct me if I'm wrong, you have 2 UART instances as lets say huart1 and huart2.

you're using huart1 then closing it with HAL_UART_DeInit(&huart1) and initializing the second one with HAL_UART_Init(&huart2)

Assuming it is like this; are you getting any messages from huart1 instance after this?

if not are you re initializing your IRQ or Callbacks? like HAL_UART_Receive_IT(&huart1,etc,etc)

Clive1 (HNL)
Senior II

Check that the callback code that deals with the pins and clocks can actually discriminate between the devices you are talking too, and that the Instance properly identifies the UART being used.

ie look at HAL_UART_MspInit() and HAL_UART_MspDeInit() and make sure they aren't brain damaged.

ranran
Senior II

Thanks clive one, I'll check it !