cancel
Showing results for 
Search instead for 
Did you mean: 

UART DMA error - What is the proper way to restart the DMA?

TSosi.1
Associate III

Hi,

I am injecting a UART DMA error by using DTCM memory and DMA2. For example:

// Induce a DMA error by using DTCM RAM for DMA2 which is inaccessible
if ( HAL_UART_Transmit_DMA( huart, transmit_buffer_dtcm_memory, num_bytes_to_transmit ) != HAL_OK )

{

// Log error

}

What happens is the frame error, parity error, and noise error interrupts are disabled after the DMA error on transmit. This I can see by the EIE bit in CR3.  HAL function UART_EndRxTransfer is called and clears EIE.

I have a streams connected to the TX and RX lines:

TX is connected to DMA2 Stream 5 - High priorty

RX is connected to DMA2 Stream 4 - High priority

 

When I try to restart the UART receiving:

if ( HAL_UART_Receive_DMA( uart_handle, receive_buffer, RX_BUF_SIZE ) != HAL_OK )
{
// Log error
}

There is a check in sub function HAL_DMA_Start_IT that returns an error because the DMA stream is busy.

 

So what is the correct way to recover/restart after a DMA and set the interrupt flags for frame, noise, and parity?\

Thanks!

 

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
TDK
Super User

Did you call HAL_UART_Abort? That should set the state machine ready again.

If you feel a post has answered your question, please click "Accept as Solution".

View solution in original post

5 REPLIES 5
TDK
Super User

Did you call HAL_UART_Abort? That should set the state machine ready again.

If you feel a post has answered your question, please click "Accept as Solution".
Karl Yamashita
Principal

If HAL status returns HAL_BUSY, then you wait a little bit and try again.

Other functions to call for status or errors, HAL_UART_GetState, HAL_UART_GetError, 

I was told that if a devices starts to smoke, put the smoke back in. I guess I never got all the smoke because the device never worked afterwards.
Don't worry, I won't byte.
TimerCallback tutorial! | UART and DMA Idle with multiple UART instances tutorial!

If you find my solution useful, please click the Accept as Solution so others see the solution.
TSosi.1
Associate III

No, but I was looking at that function. It was a long day debugging the issue and was frustrated.  I'll try it.

I tried.  The DMA stays busy. 

HAL_UART_GetError doesn't seem to return DMA error in all cases.  I noticed with a different UART that when the DMA error occurred, transfer complete was called and ErrorCode member of the UART handle was zero.

TSosi.1
Associate III

Calling HAL_UART_Abort enables the frame, parity and noise error interrupts. Thank you!