Question
How to exactly reset Timer
In my project, I have to count exact time and I am using very sensitive external oscilator. I configure it as a external timer. I have a certain number of overflow counts and waste values for my count, when it reaches the waste value, I create a capture compare interrupt and I need to reset everything about the timer. (once per second) When I compared to the GPS-assisted clock, I see that I am slipping. (1ms in for 1 minute) Thanks for now.
void TIM1_BRK_UP_TRG_COM_IRQHandler(){
if(TIM_GetITStatus(TIM1,TIM_IT_Update) != RESET){
TIM_ClearITPendingBit(TIM1,TIM_IT_Update) ;
UPEventCount ++ ,
if(UPEventCount == OSCloopValFlash){
TIM1->CCR3 = FlashPingParam.OSCOverValFlash ;
TIM1->SR &= (uint16_t)~TIM_SR_CC3IF ;
TIM1->DIER |= TIM_IT_CC3;
}
}
}
void TIM1_CC_IRQHandler(){
if(TIM_GetITStatus(TIM1, TIM_IT_CC3) != RESET){
TIM_ClearITPendingBit(TIM1, TIM_IT_CC3 );
TIM1->DIER &= (uint16_t)~TIM_IT_CC3;
TIM1 -> EGR = TIM_EGR_UG;
TIM1-> CR1 |= TIM_CR1_UDIS;
TIM1-> CR1 &= ~TIM_CR1_UDIS;
UPEventCount = 0;
TIM1->CNT &= 0;
GPIOF->ODR ^= GPIO_Pin_7;
}
}