2015-03-30 11:20 PM
Hi,
Which one is the best way of implementing stopwatch in stm32f429? Currently i am using soft timers for stopwatch. But it has time drift in long period when compared into my mobile stopwatch. I have using RTC also. Is there any method using with RTC module for stopwatch. Thanks in advance. #timer #stm32 #interrupt #!stm32f4-disco #exti2015-03-31 06:03 AM
Neither the LSI or HSI are particularly accurate, use crystals?
2015-04-02 12:50 AM
Hi Clive,
i am using external crystal 8MHz and my system core clock is 180MHZ. Even I have tried timer 2 for stopwatch. But still my stopwatch is little bit faster than mobile stopwatch. TIM_TimeBaseStructure.TIM_Prescaler = 1799; //timer input TIM_TimeBaseStructure.TIM_CounterMode = TIM_CounterMode_Up; TIM_TimeBaseStructure.TIM_Period = 1000; TIM_TimeBaseStructure.TIM_ClockDivision = 0; TIM_TimeBaseStructure.TIM_RepetitionCounter = 0; TIM_TimeBaseInit(TIM2, &TIM_TimeBaseStructure); NVIC_SetPriority(TIM2_IRQn,0); TIM_ITConfig(TIM2, TIM_IT_Update, ENABLE); TIM_ARRPreloadConfig(TIM2, ENABLE);void TIM2_IRQHandler(void){ TIM2->SR &=0xFFFE; SW_Update = 1; SW_MSecs ++; if(SW_MSecs == 100) { SW_MSecs =0; if(GPIO_ReadOutputDataBit(GPIOB,GPIO_Pin_12)) // for test, its exactly switch 1secs GPIOB->BSRRH = GPIO_Pin_12; else GPIOB->BSRRL = GPIO_Pin_12; SW_Secs ++; if(SW_Secs == 60) { SW_Secs =0; SW_Mins ++; if(SW_Mins == 60) { SW_Mins =0; } } } //}}2015-04-02 04:07 AM
2015-04-02 04:23 AM
10 ms isn't really very demanding.
I usually handle such tasks with the SysTick timer:RCC_ClocksTypeDef RCC_Clocks;
/* SysTick event each 10ms */
RCC_GetClocksFreq (&RCC_Clocks);
SysTick_Config (RCC_Clocks.HCLK_Frequency / 100);
2015-04-02 06:23 AM
Round here we'd use an oscilloscope.
Would confirm the input HSE clock, and PLL/CPU clock, via the MCO (PA8) pin.2015-04-07 05:11 AM