TIMER4 Period = fMASTER / TIM4_PRESCALER / TIM4_PERIOD = fMASTER / TIM4_PRESCALER / (ARR+1) Is the formula correct ? Is TIM4_PERIOD equal to (ARR+1) ? // Set the Autoreload bValue TIM4->ARR = 155; // 155 !
your formul is incorrect and the correct one: TIMER4 Period = fMASTER / TIM4_PRESCALER / TIM4_PERIOD = fMASTER / TIM4_PRESCALER / TIM4->ARR only when using TIMER1 you need to add +1 to the prescaler register to calculate the counter frequency (fCK_CNT is equal to fCK_PSC / (PSCR[15:0]+1). // Set the Autoreload bValue TIM4->ARR = 156; // 156 ! Regards mozra
How about the TIMER2 ? Is it similar to TIMER4 ? TIMER2 Period = fMASTER / TIM2_PRESCALER / TIM2_PERIOD = fMASTER / TIM2_PRESCALER / TIM2->ARR Is the formula correct ?