標(biāo)題: 編碼器轉(zhuǎn)速stm32測(cè)試代碼 [打印本頁]

作者: ltt123456789    時(shí)間: 2017-7-14 20:11
標(biāo)題: 編碼器轉(zhuǎn)速stm32測(cè)試代碼
分享一下

stm32單片機(jī)源程序如下:
  1. #include <stdio.h>
  2. #include <string.h>
  3. //#include <math.h>
  4. #include "stm32f10x.h"
  5. #include "stm32f10x_conf.h"
  6. #include "stm32f10x_encoder.h"
  7. #include "sys.h"
  8. #include "led.h"
  9. #include "usart.h"
  10. #include "timer.h"
  11. #include "delay.h"
  12. //#include "myspi.h"
  13. #include "exti.h"
  14. #include "wdg.h"
  15. #include "rtc.h"
  16. #include "myiic.h"
  17. #include "24cxx.h"
  18. //#define ALL_INPUT    9
  19. //#define ALL_OUTPUT   5
  20. ////--------------------------------------------------------------------------------

  21. void usart1_server(void);
  22. //void usart2_server(void);
  23. //void usart3_server(void);
  24. void Encoder_server(void);
  25. //--------------------------------------------------------
  26. int main(void)
  27. {
  28.         SystemInit();
  29.         delay_init(72);             //延時(shí)初始化
  30.         NVIC_Configuration();
  31.         Timerx_Init(100,7199);//10Khz的計(jì)數(shù)頻率,計(jì)數(shù)到5000為500ms,100為10ms
  32.         //LED_Init();
  33.         Encoder_Init();
  34.         delay_ms(100); //等待主機(jī)spi初始化完畢 非常重要!

  35.         usart1_init(9600);//USART1_Config
  36.         delay_ms(100);
  37.         IWDG_Init(IWDG_Prescaler_64,625);//1秒鐘的看門狗
  38.         delay_ms(200);
  39.         IWDG_Feed();//喂狗
  40.     while(1)
  41.     {
  42.         IWDG_Feed();//喂狗
  43.                 usart1_server();
  44.                 Encoder_server();//Printf_encoder
  45.         }
  46. }

  47. void usart1_server(void)
  48. {
  49.     //公司保密的東西就不發(fā)出來了,這里刪除了其他的,只剩一個(gè)return
  50.         return;
  51. }
  52. ……………………

  53. …………限于本文篇幅 余下代碼請(qǐng)從51黑下載附件…………
復(fù)制代碼

所有資料51hei提供下載:
編碼器測(cè)試V3.5.rar (294.59 KB, 下載次數(shù): 59)


這個(gè)是我整理好的。希望能幫到迷途中的小盤友。
啥都別廢話了直接給范例程序。^_^





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