SMT32F429 Timer Free Running
TIM_TimeBaseInitTypeDef SetupTimer;
/* Enable timer 2, using the Reset and Clock Control register */
RCC_APB1PeriphClockCmd(RCC_APB1Periph_TIM2, ENABLE);
// Get the clock frequencies
RCC_ClocksTypeDef RCC_Clocks;
RCC_GetClocksFreq(&RCC_Clocks);
SetupTimer.TIM_Prescaler = (RCC_Clocks.PCLK2_Frequency/1000000) - 1; // Prescale to 1Mhz
SetupTimer.TIM_CounterMode = TIM_CounterMode_Up;
SetupTimer.TIM_Period = 60 - 1; // 60 microsecond period
SetupTimer.TIM_ClockDivision = TIM_CKD_DIV1;
TIM_TimeBaseInit(TIM2, &SetupTimer);
TIM_Cmd(TIM2, ENABLE); // start counting by enabling CEN in CR1 */
TIM_ITConfig(TIM2, TIM_IT_Update, ENABLE); // enable so we can track each period
int count = 0;
while(1){
if (TIM_GetITStatus(TIM2, TIM_IT_Update) != RESET)
{
TIM_ClearITPendingBit(TIM2, TIM_IT_Update);
count += 1;// Insert your 60 microsecond event here
}
}
Its me