標(biāo)題: STM32和openmv串口通訊運(yùn)行速度變慢 [打印本頁]

作者: liuchao626    時(shí)間: 2021-2-17 09:27
標(biāo)題: STM32和openmv串口通訊運(yùn)行速度變慢
1.使用了仿真器下載程序
2.可以正常收發(fā)數(shù)據(jù)
3.在拔掉openmv串口后,程序起飛,正常運(yùn)行
4插上串口后,一行代碼大概跑0.5秒,屏幕刷新很慢

視頻中黑屏是放下手機(jī)在插線,各位大佬移步觀看視頻(GIF)。




作者: kaixuan_27    時(shí)間: 2021-2-17 09:27
沒有清除串口接收中斷標(biāo)志。
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    時(shí)間: 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. }
復(fù)制代碼

這是顯示數(shù)據(jù)的代碼
  1.         while(1)
  2.         {
  3.                 Gui_DrawFont_GBK16(5,5,BLUE,BLACK,"任務(wù)顯示:");
  4.                 Gui_DrawFont_GBK16(5,55,BLUE,BLACK,"進(jìn)程:");
  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);
復(fù)制代碼







歡迎光臨 (http://www.torrancerestoration.com/bbs/) Powered by Discuz! X3.1