2016-04-15 09:17 AM
Hi,
I'm building a time trial race, to do this i'm using the STM32F334R8T6 microcontroller with the RTC and timestamp, resolution must be of hundredths of a second, for this type of project is correct to use a RTC clocked at 32.768KHz?Or to have a greater accuracy is convenient to use a 32-bit timer TIMER1 with HSE clock? #rtc #timer #chronometer2016-04-15 10:31 AM
I don't recall TIM1 being 32-bit
I probably wouldn't clock it at the processor rate, 1 MHz would clearly be more than adequate. Not sure the 32.768 KHz source has the granularity/precision you are looking for.2016-04-15 11:14 AM
Hi Lollo,
I rencommend that you refer tohttp://www.st.com/web/en/resource/technical/document/application_note/DM00025071.pdf
''Using the hardware real-time clock (RTC)'', section ''Periodic timebsae/wakeup configuration for clock'' and choose which configuration between 2 and 3 is suitable to your case. -Hannibal-2016-04-19 08:53 AM
Thank you Clive1,
TIM2 is 32 bit not TIM1,in AN3371 page 9/45, to obtain an internal clock frequency of 1 Hz (ck_spre) LSE = 32.768 kHzPREDIV_A = 127PREDIV_S = 255 (for some product max 13bit = 8192)LSE = 32.768 kHzPREDIV_A = 0PREDIV_S = 32767 (in my case max 0x7FFF, see note)HSE_RTC = 1MHzPREDIV_A = 124PREDIV_S = 7999i use 32.768 KHz to obtain best precisionFraction second = 1000 - (RTC->SS)*1000)/(RTC->SynchPrediv)1/32767 = 30.52 uSecwith HSE_RTC = 1MHzFraction second = 1000 - (RTC->SS)*1000)/(RTC->SynchPrediv)1/7900 = 126.58 uSecSo if i right with RTC peripheral i only had 30.52 uSec precision,for building a chronometer is better RTC or a program with 32bit timer?NOTE:UM1786 -> HAL RTC Generic Driver -> pag 570/861 uint32_t RTC_InitTypeDef::AsynchPredivSpecifies the RTC Asynchronous Predivider value. This parameter must be a numberbetween Min_Data = 0x00 and Max_Data = 0x7F uint32_t RTC_InitTypeDef::SynchPredivSpecifies the RTC Synchronous Predivider value. This parameter must be a numberbetween Min_Data = 0x00 and Max_Data = 0x7FFF2016-04-19 10:31 AM
If I were building a reasonably time critical system, I'd use the 32-bit counter, and a TCXO rated at a few ppm.
Running at 1ms a 32-bit counter would wrap at around 49.7 days, at 0.1ms 4.97 days, and at 0.02ms just shy of a day.