|
正交解碼程序,互相學(xué)習(xí)
單片機(jī)源程序如下:
- #include "led.h"
- #include "delay.h"
- #include "key.h"
- #include "sys.h"
- #include "usart.h"
- #include "exti.h"
- #include "encode.h"
- int main(void)
- {
-
- u16 count;//編碼器計(jì)數(shù)
- delay_init(); //延時(shí)函數(shù)初始化
- uart_init(115200); //串口初始化為115200
- EXTI_PA1_Config();//編碼器Z相歸零信號(hào)外部中斷口初始化
- TIM4_Init();//定時(shí)器編碼器接口初始化
- LED_Init(); //LED端口初始化
- KEY_Init(); //初始化與按鍵連接的硬件接口
- while(1)
- {
- count = TIM4->CNT/4;//獲取計(jì)數(shù)值
- ……………………
- …………限于本文篇幅 余下代碼請(qǐng)從51黑下載附件…………
復(fù)制代碼
所有資料51hei提供下載:
STM32編碼器Demo.rar
(284.34 KB, 下載次數(shù): 66)
2017-7-31 03:01 上傳
點(diǎn)擊文件名下載附件
所有資料51hei提供下載:
|
|