cancel
Showing results for 
Search instead for 
Did you mean: 

How to use HAL_UART_receive_dma multiple times. When I modify the example project UART_TwoBoards_ComDMA (for nucleo-144 H743ZI2) with a loop of dma receive and dma transmit only the first time the received data is okay.

PeterKwek
Associate II

I connect PC6 with PC7 to get a loopback on my evaluation board.

I add the following code:

do{

memset( aRxBuffer, 0x00, sizeof(aRxBuffer));

if(HAL_UART_Receive_DMA(&UartHandle, (uint8_t *)aRxBuffer, RXBUFFERSIZE) != HAL_OK)

  {

   Error_Handler();

  }

if(HAL_UART_Transmit_DMA(&UartHandle, (uint8_t*)aTxBuffer, TXBUFFERSIZE)!= HAL_OK)

 {

Error_Handler();

 }

while( HAL_UART_GetState(&UartHandle) != HAL_UART_STATE_READY)

{

BSP_LED_Toggle(LED1);

HAL_Delay(100);

}

testCompare = memcmp(aRxBuffer,aTxBuffer, sizeof(aRxBuffer));

}

while( 1 );

Only the first time aRxBuffer contain the content of aTxBuffer.

With a logic analyser I can see transmiting data is okay.

I also see triggering of interrupt calback function HAL_UART_RxCpltCallback(), but no data in aRxBuffer.

Do I need to a special trick to receive data the second time?

0 REPLIES 0