【求助】STM32捕获频率问题

2019-08-21 12:00发布

  芯片:STM32F103RBT6,库:3.4.0,晶振:外部8MHz
下面是主要函数设置 void RCC_cfg()
{  ErrorStatus HSEStartUpStatus;
   RCC_DeInit();
   RCC_HSEConfig(RCC_HSE_ON);  
   HSEStartUpStatus = RCC_WaitForHSEStartUp();
  if(HSEStartUpStatus == SUCCESS)      
  {
    RCC_HCLKConfig(RCC_SYSCLK_Div1);
    RCC_PCLK2Config(RCC_HCLK_Div1);  
    RCC_PCLK1Config(RCC_HCLK_Div2); 
    FLASH_SetLatency(FLASH_Latency_2);  
    FLASH_PrefetchBufferCmd(FLASH_PrefetchBuffer_Enable);     
    RCC_PLLConfig(RCC_PLLSource_HSE_Div1, RCC_PLLMul_9);    
    RCC_PLLCmd(ENABLE);
    while(RCC_GetFlagStatus(RCC_FLAG_PLLRDY) == RESET) {}
    RCC_SYSCLKConfig(RCC_SYSCLKSource_PLLCLK);
    while(RCC_GetSYSCLKSource() != 0x08) {}   
  }
}

void TIME2_cfg()
{
  TIM_TimeBaseStructure.TIM_Prescaler = 0;
  TIM_TimeBaseStructure.TIM_ClockDivision =0;
  TIM_TimeBaseStructure.TIM_CounterMode = TIM_CounterMode_Up;
  TIM_TimeBaseStructure.TIM_Period =65535;
  TIM_TimeBaseInit(TIM2,&TIM_TimeBaseStructure);         
  TIM_PrescalerConfig(TIM2,0,TIM_PSCReloadMode_Immediate);
  TIM_ICInitStructure.TIM_Channel =TIM_Channel_2;
  TIM_ICInitStructure.TIM_ICPolarity = TIM_ICPolarity_Rising;
  TIM_ICInitStructure.TIM_ICSelection = TIM_ICSelection_DirectTI;
  TIM_ICInitStructure.TIM_ICPrescaler = TIM_ICPSC_DIV1;
  TIM_ICInitStructure.TIM_ICFilter = 0x0;     
  TIM_ICInit(TIM2, &TIM_ICInitStructure);      
  TIM_PWMIConfig(TIM2, &TIM_ICInitStructure);
  TIM_SelectInputTrigger(TIM2, TIM_TS_TI1FP1);  
  TIM_SelectSlaveMode(TIM2, TIM_SlaveMode_Reset); 
  TIM_SelectMasterSlaveMode(TIM2, TIM_MasterSlaveMode_Enable);
  TIM_ITConfig(TIM2, TIM_IT_CC2, ENABLE);
  TIM_Cmd(TIM2, ENABLE);
}

为什么的捕获的频率最大才是600k啊?捕获1MHz的信号根本不行!
我的设置哪个地方不对啊?!请大侠指点小弟一下!!
友情提示: 此问题已得到解决,问题已经关闭,关闭后问题禁止继续编辑,回答。