![]() |
Forum Index : Microcontroller and PC projects : CMM2 RTC & TIME$
Page 1 of 2 ![]() ![]() |
|||||
Author | Message | ||||
Chopperp![]() Guru ![]() Joined: 03/01/2018 Location: AustraliaPosts: 1097 |
Questions:- From the Manual (P14) TIMING "The Colour Maximite 2 has a battery backed clock so it will not loose the time even when powered off. If you find that the time drifts while the power is off you can use the OPTION CLOCKTRIM command to correct for any inaccuracies." I assume from this that OPPTION CLOCKTRIM only applies to the RTC & not to the internal timing of the CMM2 when it is normally running & only sets the time & date when the CMM2 is switched on? Also, does a TIME$ = TIME$ call set the CMM2 time to the RTC time? Brian ChopperP |
||||
KeepIS![]() Guru ![]() Joined: 13/10/2014 Location: AustraliaPosts: 1882 |
Clock Trim is only for the RTC and Sys time is automatically set at power up to the RTC. Mike NANO Inverter: Full download - Only Hex Ver 8.1Ks |
||||
TassyJim![]() Guru ![]() Joined: 07/08/2011 Location: AustraliaPosts: 6283 |
You have found an error in the manual. It should be OPTION RTC CALIBRATE to trim the RTC oscillator. One of my boards needs RTC CALIBRATE 140 and the other needs RTC CALIBRATE 23 so there is a big variation between boards. In the CMM2, the RTC is used for all TIME$ and DATE$ functions, not just on startup. There is no need to set the RTC specifically. PULSE and SETTICK etc use the 8MHz oscillator rather than the RTC clock. Jim VK7JH MMedit |
||||
Chopperp![]() Guru ![]() Joined: 03/01/2018 Location: AustraliaPosts: 1097 |
@Mike, That's what I thought when I read the blurb. So if the CMM2 is on 24/7, then CLOCKTRIM (once set) is of little use unless a TIME$ = TIME$ call sets the system time to the RTC time which I was told a good while ago happens with the CMM1. But then the CMM1 had a separate RTC & I may be barking up the wrong tree here. The CMM2 may continuously read the RTC. Edit Just read Jim's post. OK then, I'll stop worrying about it. Thanks I'm using CALIBRATE. Didn't notice the error. My board is running slow. Brian Edited 2020-06-16 13:13 by Chopperp ChopperP |
||||
KeepIS![]() Guru ![]() Joined: 13/10/2014 Location: AustraliaPosts: 1882 |
Yes, I should have worded that differently, I was trying to differentiate between the CCM1 and CMM2. CCM2 and ARM-H7 both have inbuilt RTC, not sure about newer MM variants. Mike. NANO Inverter: Full download - Only Hex Ver 8.1Ks |
||||
Chopperp![]() Guru ![]() Joined: 03/01/2018 Location: AustraliaPosts: 1097 |
So a SETTICK 1000, DoStuff,1 would drift over time with respect to the seconds on TIME$. Something to bear in mind. ChopperP |
||||
KeepIS![]() Guru ![]() Joined: 13/10/2014 Location: AustraliaPosts: 1882 |
I've always assumed that the xtal derived timer would not match the RTC, or use it as any sort of reference, but of course I could be wrong. If you use the system timer to time interrupt intervals set by SETTICK, you will see small variations between call times, which I expect to see due to MM basic, MM basics internal tasks and the variations of program and hardware resources. In my days, even with precision xtal clocked Micros, you still had to code critical u-sec timing tasks in assembler, perhaps that's changed over the past 20 years as smarter devices come along. NANO Inverter: Full download - Only Hex Ver 8.1Ks |
||||
Chopperp![]() Guru ![]() Joined: 03/01/2018 Location: AustraliaPosts: 1097 |
Looking at a photo of the underside of the Waveshare module, I see what looks like a watch crystal (along with the 8MHz one) which I assume is for the RTC. EDIT: Looking further down the web page, it is the 32MHz RTC crystal with calibration I would say that the 8Mhz crystal should be more accurate & stable than the RTC one. Trying the RTC CALIBRATE maxed out at -255 at the moment. Still going slow. Edited 2020-06-16 16:38 by Chopperp ChopperP |
||||
TassyJim![]() Guru ![]() Joined: 07/08/2011 Location: AustraliaPosts: 6283 |
You can go to 512 if needed. The RTC drifts with temperature: ![]() The 8MHz Xal can be replaced with a 8MHz oscillator module but it is not going have much better accuracy if any. We did this to improve video stability but by the time I did one of mine, Peter had solved the problem and the transplant is no longer required. I am not sure if the same butchery can be done with the 32kHz Xal without firmware changes. If I wanted precision, I think I would use a GPS derived timebase anyway. Jim VK7JH MMedit |
||||
matherp Guru ![]() Joined: 11/12/2012 Location: United KingdomPosts: 10310 |
Sounds like the crystal load capacitors on your board may be dodgy or incorrect value. These is a hidden option that may help OPTION RTC DRIVE n n can be between 0 and 3, it defaults to 2. Try 1 and 3 and see if one of them helps. I would start with 1 as a slow clock tend to mean the crystal is being over-driven For the avoidance of doubt, all TIME$ and DATE$ calls use the RTC |
||||
Chopperp![]() Guru ![]() Joined: 03/01/2018 Location: AustraliaPosts: 1097 |
Thanks Jim, Yes you can go from -511 to 512. Rechecked the manual 32MHz watch crystals rely a bit on body temperature to negate some of the effects from temperature variations. I've got my CMM1's time derived from a GPS. Just doing some time comparisons between TIMER & TIME$. After about 20 mins, the timer has advanced about 0.4 secs over TIME$. Over a second an hour. TIME$ itself has lost about 5 secs in a few hours which would tie in with above. (I think) Brian ChopperP |
||||
Chopperp![]() Guru ![]() Joined: 03/01/2018 Location: AustraliaPosts: 1097 |
Hi matherp Thanks for that. Will try your suggestions. Brian ChopperP |
||||
TassyJim![]() Guru ![]() Joined: 07/08/2011 Location: AustraliaPosts: 6283 |
If my RTC is running slow I use a positive calibrate value, not negative. Extract from MMTimeLord: Jim VK7JH MMedit |
||||
matherp Guru ![]() Joined: 11/12/2012 Location: United KingdomPosts: 10310 |
Jim, can you check the manual and confirm if it reads correctly. You have played with this much more than me. |
||||
Chopperp![]() Guru ![]() Joined: 03/01/2018 Location: AustraliaPosts: 1097 |
Forgot about your MMTimeLord From the manual under OPTION RTC CALIBRATE ±n Positive numbers will slow the clock down, negative will speed it up. Is the manual wrong or am I reading it incorrectly? Mine's running slow. May try +255 & see what happens. Brian ChopperP |
||||
TassyJim![]() Guru ![]() Joined: 07/08/2011 Location: AustraliaPosts: 6283 |
I think the manual is wrong but I will like to see what Brian ends up with before annoying Geoff. When I run MMTimeLord, if the average interval error is -0.0100%, ie slow, I set the Calibrate value to +100 MMTimeLord has to run for 30 minutes to negate the timing variations in the USB-TTL converter. This all assumes a computer clock that has been trimmed using NTP or similar. Jim VK7JH MMedit |
||||
matherp Guru ![]() Joined: 11/12/2012 Location: United KingdomPosts: 10310 |
Likewise I think the manual is wrong - almost certainly my fault Try the attached settick 10000,myint option milliseconds on timer=0 do loop sub myint print timer,time$ end sub with OPTION RTC CALIBRATE 500 and then OPTION RTC CALIBRATE -500 The effect is obvious within the first minute |
||||
Chopperp![]() Guru ![]() Joined: 03/01/2018 Location: AustraliaPosts: 1097 |
OK, reset to +512. See what happens in a couple of hours. -511 didn't improve anything @matherp..just saw your message. Will do later tonight Brian Edited 2020-06-16 18:46 by Chopperp ChopperP |
||||
Chopperp![]() Guru ![]() Joined: 03/01/2018 Location: AustraliaPosts: 1097 |
I can confirm that +512 speeds the RTC up. ChopperP |
||||
Chopperp![]() Guru ![]() Joined: 03/01/2018 Location: AustraliaPosts: 1097 |
OK, so after about an hour & 20mins, the RTC has gained ~2secs C/W PC clock as opposed to losing time. Also, the RTC has gained similar amount over the TIMER using my test setup. Will try Peter's routine. Update: Used Peter's routine & Jim's MMTimeLord (both similar). Got down to a cal fig of +80 Manual needs updating... Thanks Brian Edited 2020-06-16 20:43 by Chopperp ChopperP |
||||
Page 1 of 2 ![]() ![]() |
![]() |
![]() |
The Back Shed's forum code is written, and hosted, in Australia. | © JAQ Software 2025 |