I'm trying to understand how to correctly setup the timer on an STM32F10x.
The board is running with an external crystal of 16 MHz, and I'm using the PLL:
/* PLLCLK = 16MHz / 2 * 9 = 72 MHz */ RCC_PLLConfig(RCC_PLLSource_HSE_Div2, RCC_PLLMul_9);
so the board is running at 72Mhz. I'm configuring the timer as follows:
RCC_APB1PeriphClockCmd(RCC_APB1Periph_TIM3,ENABLE); TIM_TimeBaseInitTypeDef timerInitstructure; timerInitstructure.TIM_Prescaler =72000-1; timerInitstructure.TIM_CounterMode = TIM_CounterMode_Up; timerInitstructure.TIM_Period=1; timerInitstructure.TIM_ClockDivision = TIM_CKD_DIV1; timerInitstructure.TIM_RepetitionCounter=0; TIM_TimeBaseInit(TIM3,&timerInitstructure); TIM_ITConfig(TIM3, TIM_IT_Update, ENABLE); TIM_Cmd(TIM3,ENABLE);
To make sure that I set the correct frequency I am toggling a pin using the interrupt, but when I measure with the scope I get 2.784 kHz. Can anyone tell me why I get this frequency?