AnsweredAssumed Answered

Timer counter clock divide

Question asked by sh.roman on Mar 22, 2013
Latest reply on Jul 31, 2015 by sanchez.mari_paz
Hi,
does some one know  how to reduce timer counter clock?
I need to measure some pulse width  around 1ms using 16bit timer.
I have already configured the timer but I get an overflow.

 
01.TIM_ICInitStructure_sensor_echo.TIM_Channel = TIM_Channel_1;
02.TIM_ICInitStructure_sensor_echo.TIM_ICPolarity = TIM_ICPolarity_Rising;
03.TIM_ICInitStructure_sensor_echo.TIM_ICSelection = TIM_ICSelection_DirectTI;
04.TIM_ICInitStructure_sensor_echo.TIM_ICPrescaler = TIM_ICPSC_DIV1;
05.TIM_ICInitStructure_sensor_echo.TIM_ICFilter = 0x0;
06. 
07.TIM_PWMIConfig(TIM9, &TIM_ICInitStructure_sensor_echo);
08. 
09./* Select the TIM9 Input Trigger: TI1FP1 */
10.TIM_SelectInputTrigger(TIM9, TIM_TS_TI1FP1);
11. 
12./* Select the slave Mode: Reset Mode */
13.TIM_SelectSlaveMode(TIM9, TIM_SlaveMode_Reset);
14.TIM_SelectMasterSlaveMode(TIM9,TIM_MasterSlaveMode_Enable);
15. 
16./* TIM enable counter */
17.TIM_Cmd(TIM9, ENABLE);
18. 
19./* Enable the CC2 Interrupt Request */
20.TIM_ITConfig(TIM9, TIM_IT_CC2, ENABLE);
+
01.GPIO_InitStructure.GPIO_Pin =  GPIO_Pin_2;
02.  GPIO_InitStructure.GPIO_PuPd  = GPIO_PuPd_NOPULL ;
03.  GPIO_Init(GPIOA, &GPIO_InitStructure);
04. 
05. 
06.  /* Connect TIM9 pins to AF2 */ 
07.  GPIO_PinAFConfig(GPIOA, GPIO_PinSource1, GPIO_AF_TIM5);
08. 
09.   NVIC_InitTypeDef NVIC_InitStructure;
10. 
11.      /* TIM9 clock enable */
12.     RCC_APB2PeriphClockCmd(RCC_APB2Periph_TIM9, ENABLE);
13. 
14.     /* Connect TIM pin to AF2 */
15.     GPIO_PinAFConfig(GPIOA, GPIO_PinSource2, GPIO_AF_TIM9);
16. 
17./* Enable the TIM9 global Interrupt */
18.  NVIC_InitStructure.NVIC_IRQChannel = TIM1_BRK_TIM9_IRQn;
19.  NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0;
20.  NVIC_InitStructure.NVIC_IRQChannelSubPriority = 1;
21.  NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
22.  NVIC_Init(&NVIC_InitStructure);

Outcomes