cancel
Showing results for 
Search instead for 
Did you mean: 

[STM32F7] Overrun error with USART6

smrtkai
Senior
Posted on August 25, 2016 at 09:42

Hi,

I am using a STM32F746NG discovery board. My project is supposed to receive, display and store data. It receives data over USART6 in asynchronous mode using DMA. To display the data I want to use the STemWin library. 

When I compile my project with the STemWin library the USART DMA interrupts are not executed anymore.

I have no clue what the problem might be and how to debug it. Can anyone give me some advice?

3 REPLIES 3
smrtkai
Senior
Posted on August 25, 2016 at 11:47

USART6 got on overrun error, when I activated STemWin. My current solution is to ''disable overrun'' in STM32CubeMX.

EDIT:

This is just a bad workaround. By disabling overrun errors, I am missing data. And I would like to know how often an overrun occurs. Therefore I would like to handle the error appropriately in HAL_UART_ErrorCallback(UART_HandleTypeDef *huart). What do I have to do, to discard the data and resume data receiving?

How can I avoid overrun errors? It does not seem to be enough to set the USART interrupt priority at the highest priority.

My USART interface is configured with 115.200 baud/s, 8 data bits, no parity and 1 stop bit. The data stream is roughly 51.200 bits/s (8 data bytes with a frequency of 800Hz).
smrtkai
Senior
Posted on August 29, 2016 at 10:27

Does an Reference Manual exist for STM32F7-microcontroller?

EDIT:

Found the Reference Manual. I was not able to find the Reference Manual over google ''stm32f7 reference manual'' and searching for the same term on st.com shows ''1237 Ressources''. But searching only for ''STM32F7 reference'' on st.com did the trick. Strange behaviour.

http://www.st.com/content/ccc/resource/technical/document/reference_manual/c5/cf/ef/52/c0/f1/4b/fa/DM00124865.pdf/files/DM00124865.pdf/jcr:content/translations/en.DM00124865.pdf

The Reference Manual states:

Overrun error

An overrun error occurs when a character is received when RXNE has not been reset. Data can not be transferred from the shift register to the RDR register until the RXNE bit is cleared. The RXNE flag is set after every byte received. An overrun error occurs if RXNE flag is set when the next data is received or the previous DMA request has not been serviced. When an overrun error occurs:

• The ORE bit is set.

• The RDR content will not be lost. The previous data is available when a read to

USART_RDR is performed.

• The shift register will be overwritten. After that point, any data received during overrun

is lost.

• An interrupt is generated if either the RXNEIE bit is set or EIE bit is set.

• The ORE bit is reset by setting the ORECF bit in the ICR register.

Note: The ORE bit, when set, indicates that at least 1 data has been lost. There are two

possibilities:

- if RXNE=1, then the last valid data is stored in the receive register RDR and can be read,

- if RXNE=0, then it means that the last valid data has already been read and thus there is

nothing to be read in the RDR. This case can occur when the last valid data is read in the

RDR at the same time as the new (and lost) data is received.

So I assume, I have to program my own interrupt handler.

smrtkai
Senior
Posted on August 29, 2016 at 17:52

I have found a solution.

I re-initialize the usart interface after starting the DMA. This prevents the overrun error, which seems to occur during the initialization. It seems that the usart interface is receiving data before ''HAL_UART_Receive_DMA'' is called. 

HAL_UART_Receive_DMA(&UART_RX_HANDLE, (uint8_t *) rxDMABuffer, UART_RX_BUFFER_SIZE);

// HACK: re-initialize usart due to overrun error at startup

MX_USART6_UART_Init();