标题: STM32和openmv串口通讯运行速度变慢 [打印本页]

作者: liuchao626    时间: 2021-2-17 09:27
标题: STM32和openmv串口通讯运行速度变慢
1.使用了仿真器下载程序
2.可以正常收发数据
3.在拔掉openmv串口后,程序起飞,正常运行
4插上串口后,一行代码大概跑0.5秒,屏幕刷新很慢

视频中黑屏是放下手机在插线,各位大佬移步观看视频(GIF)。




作者: kaixuan_27    时间: 2021-2-17 09:27
没有清除串口接收中断标志。
void DEBUG_USART_IRQHandler(void)
{
        if(USART_GetITStatus(DEBUG_USARTx,USART_IT_RXNE)!=RESET)
        {      
                temp_head[0] = USART_ReceiveData(DEBUG_USARTx);
                 
        }
        USART_ClearITPendingBit(DEBUG_USARTx, USART_IT_RXNE);
        USART_ClearFlag(DEBUG_USARTx, USART_FLAG_RXNE);
}
作者: liuchao626    时间: 2021-2-17 09:34
这是串口中断
  1. void DEBUG_USART_IRQHandler(void)
  2. {
  3.         if(USART_GetITStatus(DEBUG_USARTx,USART_IT_RXNE)!=RESET)
  4.         {       
  5.                 temp_head[0] = USART_ReceiveData(DEBUG_USARTx);
  6.                  
  7.         }
  8. }
复制代码

这是显示数据的代码
  1.         while(1)
  2.         {
  3.                 Gui_DrawFont_GBK16(5,5,BLUE,BLACK,"任务显示:");
  4.                 Gui_DrawFont_GBK16(5,55,BLUE,BLACK,"进程:");
  5.                 Gui_DrawFont_Num32(0 ,20,GREEN,BLACK,Num[2]);
  6.                 Gui_DrawFont_Num32(0 ,20,BLACK,BLACK,Num[2]);
  7.                 Gui_DrawFont_Num32(0 ,20,GREEN,BLACK,Num[3]);
  8.                 Gui_DrawFont_Num32(0 ,20,BLACK,BLACK,Num[3]);
  9.                 Gui_DrawFont_Num32(0 ,20,GREEN,BLACK,Num[4]);
  10.                 Gui_DrawFont_Num32(0 ,20,BLACK,BLACK,Num[4]);
  11.                
  12.                 Gui_DrawFont_Num32(25,20,GREEN,BLACK,Num[2]);
  13.                 Gui_DrawFont_Num32(50,20,GREEN,BLACK,Num[3]);
  14.                 Gui_DrawFont_GBK16(82,30,RED,BLACK,"+");
  15.                 Gui_DrawFont_Num32(90,20,GREEN,BLACK,Num[1]);
  16.                 Gui_DrawFont_Num32(115,20,GREEN,BLACK,Num[2]);
  17.                 Gui_DrawFont_Num32(140,20,GREEN,BLACK,Num[3]);
  18.                 USART_SendData(DEBUG_USARTx,0xA2);
  19.                 sprintf((char*)cx_buf,"cx:%08X",temp_head[2]);
  20.                 Gui_DrawFont_GBK16(5,80,RED,BLACK,cx_buf);
复制代码







欢迎光临 (http://www.51hei.com/bbs/) Powered by Discuz! X3.1