欧美极品高清xxxxhd,国产日产欧美最新,无码AV国产东京热AV无码,国产精品人与动性XXX,国产传媒亚洲综合一区二区,四库影院永久国产精品,毛片免费免费高清视频,福利所导航夜趣136

標(biāo)題: STM32F4正交解碼編碼器源碼 [打印本頁(yè)]

作者: jiangzecui    時(shí)間: 2018-10-8 12:49
標(biāo)題: STM32F4正交解碼編碼器源碼
STM32F4  正交解碼編碼器

單片機(jī)源程序:
  1. #include "sys.h"
  2. #include "ENCODER.h"



  3. //TIM5_CH1 ----- PA0
  4. //TIM5_CH2 ----- PA1

  5. void Encoder_Configuration(void)//編碼器模式
  6. {
  7.     GPIO_InitTypeDef gpio;
  8.    
  9.     RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOA|RCC_AHB1Periph_GPIOC,ENABLE);
  10.     RCC_APB1PeriphClockCmd( RCC_APB1Periph_TIM5|RCC_APB1Periph_TIM3 ,ENABLE);
  11.    
  12.     gpio.GPIO_Pin = GPIO_Pin_0 | GPIO_Pin_1;
  13.     gpio.GPIO_Mode = GPIO_Mode_AF;
  14.     gpio.GPIO_OType = GPIO_OType_PP;
  15.     gpio.GPIO_PuPd = GPIO_PuPd_NOPULL;
  16.     gpio.GPIO_Speed = GPIO_Speed_100MHz;
  17.    
  18.      GPIO_Init(GPIOA,&gpio);
  19.     gpio.GPIO_Pin = GPIO_Pin_6 | GPIO_Pin_7;       
  20.         GPIO_Init(GPIOC,&gpio);

  21.     GPIO_PinAFConfig(GPIOA, GPIO_PinSource0,  GPIO_AF_TIM5);
  22.     GPIO_PinAFConfig(GPIOA, GPIO_PinSource1,  GPIO_AF_TIM5);
  23.    
  24.         GPIO_PinAFConfig(GPIOC, GPIO_PinSource6,  GPIO_AF_TIM3);
  25.     GPIO_PinAFConfig(GPIOC, GPIO_PinSource7,  GPIO_AF_TIM3);
  26.        
  27.     TIM_EncoderInterfaceConfig(TIM5, TIM_EncoderMode_TI12, TIM_ICPolarity_Rising, TIM_ICPolarity_Rising);
  28.         TIM_EncoderInterfaceConfig(TIM3, TIM_EncoderMode_TI12, TIM_ICPolarity_Rising, TIM_ICPolarity_Rising);
  29.     TIM_Cmd(TIM5, ENABLE);
  30.                     TIM_Cmd(TIM3, ENABLE);
  31. }
復(fù)制代碼

所有資料51hei提供下載:
正交解碼編碼器.rar (479.76 KB, 下載次數(shù): 124)







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