2015-06-03 02:24 AM
hello,
I use the stm32f103VD,Clock 48MHz from the 8MHz HSI.Can you help me and tell me if I configured the timer 3 correctly for counter each 1ms ?I am not sure it's correct because the iterruption comes each 0.000999 ms ! I didn't understand why. any help plz ?the code: //enable the timer clock RCC_APB1PeriphClockCmd(RCC_APB1Periph_TIM3, ENABLE); //compute the prescaler value PrescalerValue = (uint16_t) (SystemCoreClock / 1000000) - 1; //time base configuration TIM_TimeBaseStructure.TIM_Period = 1 * 1000; TIM_TimeBaseStructure.TIM_Prescaler = PrescalerValue; TIM_TimeBaseStructure.TIM_ClockDivision = 0; TIM_TimeBaseStructure.TIM_CounterMode = TIM_CounterMode_Up; TIM_TimeBaseInit(TIM3, &TIM_TimeBaseStructure); //enable timer interrupt TIM_ITConfig(TIM3, TIM_IT_Update, ENABLE); //enable timer counter TIM_Cmd(TIM3, ENABLE);thanks #stm32-timer-inerrupt2015-06-03 05:49 AM
iterruption comes each 0.000999 ms !
I'm just going to assume you mistyped that, as interrupting faster than a micro-second seems rather implausible. A micro-second short of a milli-second? Well the HSI isn't a high accuracy clock, have you looked at this in percent-error term? Consider using a more accuracy clock source. Also the Period should be 1000-1, but that will make it a tad faster still.2015-06-03 06:37 AM
Sorry ! there is an error...
'' the iterruption comes each
0.000999 s
so each
0.999 ms
! ''
If I understand, so the period must be 1000 - 1 to have an interrupt at 1ms ??2015-06-03 07:46 AM
Well making the number smaller will shrink the time further
999us instead of 1000us represents an error of 0.1%. HSI is specified to have error in the +/-2.5% or so range, over temperature. You might want to measure the HSI or PLL frequencies via the MCO (PA8) pin to understand what they look like.