找回密碼
 立即注冊(cè)

QQ登錄

只需一步,快速開始

搜索
查看: 1591|回復(fù): 0
收起左側(cè)

stm32F407編碼器讀取角度代碼

[復(fù)制鏈接]
ID:1067179 發(fā)表于 2023-3-18 20:05 | 顯示全部樓層 |閱讀模式
stm32F407編碼器讀取角度代碼,需要請(qǐng)自取

單片機(jī)源程序如下:
  1. #include "sys.h"
  2. #include "delay.h"
  3. #include "usart1.h"
  4. #include "usart2.h"
  5. #include "usart3.h"
  6. #include "key.h"
  7. #include "soft_timer.h"
  8. #include "multi_button.h"

  9. #include "tim_encode.h"

  10. int main()
  11. {
  12.         u64 xitong_haomiao_printf_old;
  13.         delay_init();
  14.         USART1_Init(115200);
  15.         USART2_Init(115200);
  16.         USART3_Init(115200);

  17.     TIM4_Encode_Test();
  18.     while(1)
  19.     {
  20.    
  21.     }
  22.    
  23.         SoftTimer_Init();
  24.         Multi_Button_Init();
  25.         Key_Scan_Init();
  26.        
  27.         while(1)
  28.         {
  29.                 if(USART1_RX_STA&0x8000)
  30.                 {               
  31.                         USART1_printf("USART1_Read %3d個(gè):%s",(USART1_RX_STA&0x7fff),USART1_RX_BUF);
  32.                         USART1_RX_STA=0;
  33.                 }
  34.                 if(USART2_RX_STA&0x8000)
  35.                 {               
  36.                         USART2_printf("USART2_Read %3d個(gè):%s",(USART2_RX_STA&0x7fff),USART2_RX_BUF);
  37.                         USART2_RX_STA=0;
  38.                 }
  39.                 if(USART3_RX_STA&0x8000)
  40.                 {               
  41.                         USART3_printf("USART3_Read %3d個(gè):%s",(USART3_RX_STA&0x7fff),USART3_RX_BUF);
  42.                         USART3_RX_STA=0;
  43.                 }
  44.                 if(xitong_haomiao-xitong_haomiao_printf_old>=1000)
  45.                 {
  46.                         xitong_haomiao_printf_old=xitong_haomiao;
  47.                         printf       ("USART1_ms=%llu\r\n",xitong_haomiao/1000);
  48.                         USART2_printf("USART2_ms=%llu\r\n",xitong_haomiao/1000);
  49.                         USART3_printf("USART3_ms=%llu\r\n",xitong_haomiao/1000);
  50.                 }
  51.                 if(Key!=KEY_NO_PRES)
  52.                 {
  53.                         if(Key==KEY0_PRES)
  54.                         {
  55.                                 printf("key0\r\n");
  56.                         }
  57.                         Key=KEY_NO_PRES;
  58.                 }
  59.         }
  60. }

復(fù)制代碼
Keil代碼下載:
程序.7z (389.04 KB, 下載次數(shù): 22)


回復(fù)

使用道具 舉報(bào)

本版積分規(guī)則

手機(jī)版|小黑屋|51黑電子論壇 |51黑電子論壇6群 QQ 管理員QQ:125739409;技術(shù)交流QQ群281945664

Powered by 單片機(jī)教程網(wǎng)

快速回復(fù) 返回頂部 返回列表