cancel
Showing results for 
Search instead for 
Did you mean: 

USART1 behaved abnormal

paker earth
Associate II

hello all

I established a virtual com port using a 4G modem, connected it with my F413ZH USART1.

I used a DMA channel for RX. set HAL_UART_Receive_DMA(&huart1, (uint8_t *)&RxS0, 1);

I could get datas from it at first. DMA2_Stream0_IRQHandler() will be called.

When I power off modem, then reconnect it.

I could only transmit datas out, but couldn't receive any datas from USART1.

DMA2_Stream0_IRQHandler() has no response.

After I reboot STM32 device, everything becomes fine.

If anyone knows how to solve it, please kindly tell me.

Thank you very much.

5 REPLIES 5

Does the DMA flags any errors? What? Can you restart?

Does the USART flags some framing or noise error? What? Can you clear?

Does the USART flag RXNE? Does polling or interrupt methods work?

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
paker earth
Associate II

Thank you for your reply.

In my opinion, when data is coming, isr function DMA2_Stream2_IRQHandler() need to be called first.

Then I could debug software issue, but in my case isr funtion is never be called.

My understanding is right?

dirty solution is to reset USART1.

paker earth
Associate II

Hello Clive Two.Zero

It seems to have frame error.

see attachment.

"busy and no error".

HAL_DMA_GetState[2], HAL_DMA_GetError[0] 

HAL_UART_GetState[34], HAL_UART_GetError[0] 

change to "ready and frame error"

HAL_DMA_GetState[1], HAL_DMA_GetError[0] 

HAL_UART_GetState[32], HAL_UART_GetError[4] 

but it is being clear later.

Your ISR won't get called if the USART is in no fit state to receive things.

Not sure what the logs supposed to show me. Look at the content of the USART_SR directly and clear error states.​

Work backwards, you don't get an ISR, focus why it is not happen, not the fact it is happening. ​

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
Bob S
Principal

I bet when you power down the modem it pulls its UART Tx line low (the STM32's UART RX). That gives you the framing error. And in HAL, a framing error halts DMA receive (see HAL_UART_IRQHandler()). When you get a framing error, you need to re-start the receive process by calling HAL_UART_Receive_DMA() again.