|
0.png (7.17 KB, 下載次數(shù): 91)
下載附件
2017-8-4 01:07 上傳
- #include "led.h"
- #include "delay.h"
- #include "key.h"
- #include "sys.h"
- #include "usart.h"
- #include "exti.h"
- #include "encode.h"
- #include "timer.h"
- extern double w;
- extern int x,y,buff,num;
- u16 count;//編碼器計(jì)數(shù)
- int main(void)
- {
-
- delay_init(); //延時(shí)函數(shù)初始化
- uart_init(115200); //串口初始化為115200
- EXTI_PA1_Config();//編碼器Z相歸零信號(hào)外部中斷口初始化
- TIM6_Int_Init(49999,7199);//10Khz的計(jì)數(shù)頻率,計(jì)數(shù)到49999為500ms
- TIM4_Init();//定時(shí)器編碼器接口初始化
- LED_Init(); //LED端口初始化
- KEY_Init(); //初始化與按鍵連接的硬件接口
- while(1)
- {
- count = TIM4->CNT/4;//獲取計(jì)數(shù)值
- delay_ms(100);//每隔1s打印一次編碼器角度,用手去撥動(dòng)編碼器 使其慢速旋轉(zhuǎn)
- printf("count = %d\n ",count);
- // printf("num = %d\n ",num);
- // printf("x = %d\n ",x);
- // printf("y = %d\n ",y);
- // printf("w = %lf\n ",w);
- }
- }
復(fù)制代碼
編碼器測(cè)位置.rar
(288.87 KB, 下載次數(shù): 92)
2017-8-4 01:08 上傳
點(diǎn)擊文件名下載附件
編碼器測(cè)位置 下載積分: 黑幣 -5
|
評(píng)分
-
查看全部評(píng)分
|