cancel
Showing results for 
Search instead for 
Did you mean: 

Timeout on usart2 with DMA

fab04
Associate II

Hi everybody,

I'm using a STM32L476RG. I use the usart2 to transmit/receive frames from an external sensor. The reception is working with DMA1 channel6 (I use Transfer complete and idle line interrupts), and it works very well.

I'd like to add a timeout to prevent the non reception of a frame.

My sensor is supplied in 12V and microcontroller is asking it ervery 0.5s. Sensor responds directly.

To simulate a broken sensor, I just unplug it from supply, so microcontroller doesn't receive any frame. When I plug again my sensor, I can see that the sensor is responding (on a terminal (docklight)) but not my microcontroller.

By checking registers, I see that idle line IT is generated but no TC interrupt. I see, also that my DMA buffer doesn't receive any character (as it was blocked). I tried to reset DMA, flag IT, and nothing happens.

Have you some ideas to help me on this point ?

Fabrice

4 REPLIES 4

Handle UART errors, particularly overflow.

JW

fab04
Associate II

Effectively, overrun flag is set. I'll check that and let you inform.

fab04
Associate II

Thank you for the documentation, it seems to be what happen.

I've try to detect overrun error and read RDR buffer to clear IT flag, but it's the same, it doesn't start again.

fab04
Associate II

by making a reset of DMA/UART, it works but it's a weird method.