2022-09-15 03:02 AM
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?
2022-09-15 08:47 AM
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:
When your question is answered, please close this topic by choosing Select as Best. This will help other users find that answer faster.
Imen
2022-09-16 07:32 AM
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);
}
}
}