cancel
Showing results for 
Search instead for 
Did you mean: 

STM32CubeMX H723 FW_H7 V1.10.0 Uart DMA can not work

SShi.4
Associate

I am working on STM32H723, I use STM32CubeMX and pack FW_H7 V1.10.0 to auto create code. I used 9 uarts, each have DMA for RX, and RXbuffer size if 512. I send data to each uart port 256 bytes one time. Then, the first time, uart report it received 256 bytes, second time, uart report it received 512 bytes, but the 512 bytes buffer's first 256 byte is zero, the last 256 bytes it the new data, and then ,the uart cannot receive any data anymore. If I use FW_H7 V1.9.0, DMA for uart RX worked OK, but, under FW_H7 V1.9.0, lwip + eth can not work.

If there is anyone who can help me whth this problem?

2 REPLIES 2
Imen.D
ST Employee

Hello @SShi.4​ and welcome to the Community 🙂

Please have a look at this application note which contains a list of examples about 2 distinct topics: 

  • Receiving data with UART and DMA when application does not know in advance size of bytes to be received
  • Transmitting data with UART and DMA to avoid CPU stalling and use CPU for other purposes

When your question is answered, please close this topic by choosing Select as Best. This will help other users find that answer faster.

Imen

When your question is answered, please close this topic by clicking "Accept as Solution".
Thanks
Imen

Hi Imen,

Thanks very much.

I have tried IDLE interrupt for UART DMA receiving. __HAL_UART_ENABLE_IT(&huart1, UART_IT_IDLE);

Under V1.9.0, it works well, I can receive unknown size data. But under V1.10.0, it still the same problem.

Here is my code:

in main function:

__HAL_UART_ENABLE_IT(&huart1, UART_IT_IDLE);

HAL_UART_Receive_DMA(&huart1, (uint8_t *)pData, 255);

it.c file:

void USART1_IRQHandler(void)

{

 /* USER CODE BEGIN USART1_IRQn 0 */

 USER_UART_RxCpltCallback(&huart1);

 /* USER CODE END USART1_IRQn 0 */

 HAL_UART_IRQHandler(&huart1);

 /* USER CODE BEGIN USART1_IRQn 1 */

 /* USER CODE END USART1_IRQn 1 */

}

void USER_UART_RxCpltCallback(UART_HandleTypeDef *huart)

{

if(huart->Instance == USART1)

{

if(__HAL_UART_GET_FLAG(&huart1, UART_FLAG_IDLE) != RESET)

{

__HAL_UART_CLEAR_IDLEFLAG(&huart1); //清除IDLE标志

uint8_t Len = 255 - __HAL_DMA_GET_COUNTER(&hdma_usart1_rx);

HAL_UART_DMAStop(&huart1);//�?�止DMA,为了�?新设置DMA�?��?多少数�?�

HAL_UART_Transmit_DMA(&huart1, (uint8_t *)pData, Len);

HAL_UART_Receive_DMA(&huart1, (uint8_t *)pData, 255);

}

}

}