STM32
直播中

石飞鹏

7年用户 908经验值
私信 关注
[问答]

stm32f103zet串口接收完成不了,进不了回调怎么解决?

芯片STM32f103zet,用串口1和串口2;
串口1,DMA循环模式接收1字节,处理用户输入命令,
串口2,DMA普通模式接收512字节,解析GPS信息,

问题1:串口2启动DMA,HAL_UART_Receive_DMA( huart2,  GPSRxBuff[0], 512); 只可以完成一次,下次启动不能完成。

在启动DMA时加入清除错误标志的语句

  • void GPS_UART_Start(void)
  • {
  •     /* Start the receiver */
  •     __HAL_UART_CLEAR_OREFLAG( hGPS);
  •         if(hGPS.State == HAL_UART_STATE_READY || hGPS.State == HAL_UART_STATE_BUSY_TX)
  • //                HAL_UART_Receive( hGPS,  GPSRxBuff[0], 512,1000);
  •                 HAL_UART_Receive_DMA( hGPS,  GPSRxBuff[0], 511);
  • }


回帖(1)

刘兵

2024-5-14 09:50:07
内存增量设置好了么



  • hdma_usart2_rx.Instance = DMA1_Channel6;
  •     hdma_usart2_rx.Init.Direction = DMA_PERIPH_TO_MEMORY;
  •     hdma_usart2_rx.Init.PeriphInc = DMA_PINC_DISABLE;
  •     hdma_usart2_rx.Init.MemInc = DMA_MINC_ENABLE;
  •     hdma_usart2_rx.Init.PeriphDataAlignment = DMA_PDATAALIGN_BYTE;
  •     hdma_usart2_rx.Init.MemDataAlignment = DMA_MDATAALIGN_BYTE;
  •     hdma_usart2_rx.Init.Mode = DMA_NORMAL;
  •     hdma_usart2_rx.Init.Priority = DMA_PRIORITY_LOW;
  •     HAL_DMA_Init( hdma_usart2_rx);



举报

更多回帖

发帖
×
20
完善资料,
赚取积分