Question
Timer using external clock nr 2
Posted on June 22, 2012 at 12:56
I'm using a STM32F103RBT6.
Basicly I want to clock TIM1 (it should work on this frequency because of the Fmax from APB2) external with an 25.5 Mhz signal and use the Update_IRQ. Thats all.I can start TIM1 and use the Update Interrupt with this code: TIM_TimeBase_InitStructure.TIM_ClockDivision = TIM_CKD_DIV1; TIM_TimeBase_InitStructure.TIM_CounterMode = TIM_CounterMode_Up; TIM_TimeBase_InitStructure.TIM_Period = 10000; TIM_TimeBase_InitStructure.TIM_Prescaler = 0; TIM_TimeBaseInit(TIM1, &TIM_TimeBase_InitStructure); //space to add code for clock switching TIM_ITConfig(TIM1, TIM_IT_Update, ENABLE); TIM_Cmd(TIM1, ENABLE);and my ISR:void TIM1_UP_IRQHandler(void){ USB_SEND_TEST(); TIM_ClearITPendingBit(TIM1, TIM_IT_Update);}this is working well ... but now I like to change the TIM1 internal clock to an external clock like it done here :https://my.st.com//public/STe2ecommunities/mcu/Lists/STM32Discovery/Timer%20using%20external%20clock
I have init the GPIO PB14 with clock on and as floating input. I can read the GPIO and I see it changing like i change the input in hardware.I tried to put this code (and a quite variants of it) insite my TIM1 init but this is not function... // External Trigger set to External Clock, Mode 1 TIM_ETRClockMode1Config (TIM1, TIM_ExtTRGPSC_OFF, TIM_ExtTRGPolarity_NonInverted, 0); // Input Trigger selection TIM_TIxExternalClockConfig (TIM1, TIM_TIxExternalCLK1Source_TI2, TIM_ICPolarity_Rising, 0) ; //TIM_SelectInputTrigger (TIM1, TIM_TS_TI2FP2); // Slave Mode selection: Trigger Mode TIM_SelectSlaveMode(TIM1, TIM_SlaveMode_External1);Or should I use external clock mode 2 better? It is very importent that the STM32 do not lose any edges even on high frequency. In the application I like to use the STM32F105xx MCU. #stm32vldiscovery-timer-external