1024手机基地看电影,午夜福利视频导航,国产精品福利在线一区,亚洲欧美日韩另类成人,在线观看午夜日本理论片,成年超爽免费网站,国产精品成人免费,精品动作一级毛片,成人免费观看网站,97精品伊人久久大香蕉

標(biāo)題: stm32設(shè)置編碼器接口后計(jì)數(shù)器不計(jì)數(shù)是什么情況 [打印本頁]

作者: 電子小萌    時(shí)間: 2020-4-4 10:53
標(biāo)題: stm32設(shè)置編碼器接口后計(jì)數(shù)器不計(jì)數(shù)是什么情況
如題  求解

  1. void Coder_Configure1()
  2. {
  3.     GPIO_InitTypeDef GPIO_InitStructure;
  4.     TIM_TimeBaseInitTypeDef TIM_TimeBaseInitStructure;
  5.     TIM_ICInitTypeDef TIM_ICInitStructure;
  6.     RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA|RCC_APB2Periph_TIM1,ENABLE);
  7.     RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOB,ENABLE);
  8.        
  9.     GPIO_InitStructure.GPIO_Pin = GPIO_Pin_8|GPIO_Pin_9;
  10.           GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING;
  11.     GPIO_InitStructure.GPIO_Speed= GPIO_Speed_50MHz;
  12.     GPIO_Init(GPIOB,&GPIO_InitStructure);
  13.        
  14.    TIM_DeInit(TIM1);
  15.     TIM_TimeBaseInitStructure.TIM_Period = 0XFF;  //Tout= ((arr+1)*(psc+1))/Tclk
  16.     TIM_TimeBaseInitStructure.TIM_Prescaler = 0;TIM_TimeBaseInitStructure.TIM_CounterMode = TIM_CounterMode_Up;
  17.     TIM_TimeBaseInitStructure.TIM_ClockDivision = TIM_CKD_DIV1;TIM_TimeBaseInitStructure.TIM_RepetitionCounter = 1;
  18.     TIM_TimeBaseInit(TIM1,&TIM_TimeBaseInitStructure);
  19.       
  20.     TIM_EncoderInterfaceConfig(TIM1, TIM_EncoderMode_TI12,
  21.                                      TIM_ICPolarity_Rising,
  22.                                      TIM_ICPolarity_Rising);
  23.     TIM_ICInitStructure.TIM_Channel = TIM_Channel_1;  
  24.     TIM_ICStructInit(&TIM_ICInitStructure);
  25.    
  26.    
  27.     TIM_ICInitStructure.TIM_Channel = TIM_Channel_2;   
  28.     TIM_ICStructInit(&TIM_ICInitStructure);
  29.                
  30.     TIM_SetCounter(TIM1, 0);   
  31.     TIM_Cmd(TIM1,ENABLE);
  32. }
  33.       
  34. void Coder_Configure4()
  35. {
  36.     GPIO_InitTypeDef GPIO_InitStructure;
  37.     TIM_TimeBaseInitTypeDef TIM_TimeBaseInitStructure;
  38.     TIM_ICInitTypeDef TIM_ICInitStructure;
  39.     RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOB,ENABLE);
  40.     RCC_APB1PeriphClockCmd(RCC_APB1Periph_TIM4,ENABLE);
  41.        
  42.           GPIO_InitStructure.GPIO_Pin = GPIO_Pin_6|GPIO_Pin_7;
  43.           GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING;
  44.     GPIO_InitStructure.GPIO_Speed= GPIO_Speed_50MHz;
  45.     GPIO_Init(GPIOB,&GPIO_InitStructure);

復(fù)制代碼


作者: 電子小萌    時(shí)間: 2020-4-4 12:01
有人可以幫忙解答一下嗎




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