Crystal Oscillator Accuracy #1483
Replies: 15 comments
-
Posted at 2015-08-27 by @gfwilliams A build with this in will be available here shortly. The timing is way better as would be expected, but I'm totally unconvinced about the timing that's being got from Deep Sleep. |
Beta Was this translation helpful? Give feedback.
-
Posted at 2015-08-27 by asez73 I don't have your answer but this ST Application note is deeply linked to crystals on STM32 family and might help you.
Frankly I totally lost just from this document. |
Beta Was this translation helpful? Give feedback.
-
Posted at 2015-08-28 by @gfwilliams Thanks - it's more a matter of looking at the external crystals themselves though (rather than the chip). I know only too well how rubbish the internal low-speed oscillator on the STM32F4 is :) Some chips allow you to calibrate the internal RC oscillators, but it seems the STM32 doesn't. The best I can do is to change the divisor (which is usually 32768), but even that seems hard to do on the fly. I do have a branch with some code in, but I can't get it working reliably. If 32kHz crystals aren't actually much more accurate than the 8Mhz ones, then it's not such a big deal switching over to use the 8Mhz crystal on the Pico. |
Beta Was this translation helpful? Give feedback.
-
Posted at 2015-08-28 by asez73 They have an application note about calibrating the RTC from an external clock and, or do some smooth adjustments in orders to compensate for temperature changes, which could be used from time to time when the Pico or Standard boards are awaken and thus 'correct' the LSI clock. I also actually missed the capability to create a directory on SDcard. That's mainly to avoid sd wear problem. I turned around this by creating the whole tree structure on a PC before starting the experiment. |
Beta Was this translation helpful? Give feedback.
-
Posted at 2015-08-28 by @gfwilliams
Sadly the RTC is around 100,000 ppm out - so can't be calibrated like that :( I guess I could save the prescaler alongside the saved code, and could then load it at boot-time. It wouldn't be dynamic, but I guess it would actually make a really big improvement as I think the drift isn't that high - it's the change in frequency between individual chips that really sucks. You could always solder a watch crystal on and it'll magically use that and make really good time :) Good point about creating directories. I'll file a bug for it. |
Beta Was this translation helpful? Give feedback.
-
Posted at 2015-08-28 by asez73 I have a 1v4 Espruino board and a Kickstarter Pico. So I am not totally sure this would help with temperature. Now it seems that the HSI is more precise than that and could be used to calibrate the RTC or LSI... |
Beta Was this translation helpful? Give feedback.
-
Posted at 2015-08-28 by fdufnews Timing accuracy is one part of the problem. You shall consider power consumption too. I'm sure using the 32kHz oscillator will by much more efficient than using the 8MHz one in deep sleep mode. |
Beta Was this translation helpful? Give feedback.
-
Posted at 2015-08-28 by @gfwilliams Well, the build that'd linked above:
So you get the best of both worlds. It means it'll be accurate normally, but if you use |
Beta Was this translation helpful? Give feedback.
-
Posted at 2015-08-28 by asez73 I dig a bit more and found some examples on github about using lsi to autocalibrate the rtc |
Beta Was this translation helpful? Give feedback.
-
Posted at 2015-08-28 by @gfwilliams Is your Espruino 1v4 not keeping good time either? That should have a proper 32kHz crystal on it? Thanks! That's basically what I was doing in the branch I have that doesn't work very well, but there are some issues:
So I could actually expose that functionality as a function, ... or if I'm using the HSE for timekeeping, I could keep track what the LSI speed was all the time - and when I go into Deep Sleep I could adjust the amount of ticks I sleep for with that in mind... So not trying to 'fix' the LSI speed, but actually just being aware of it and working around it. |
Beta Was this translation helpful? Give feedback.
-
Posted at 2015-08-28 by asez73 Yes, my Espruino 1v4 did not kept accurately time with interpreter 1v72 in spite of its external 32 khz... |
Beta Was this translation helpful? Give feedback.
-
Posted at 2015-08-28 by @gfwilliams Frustrating about the 1v4 - I'll test it when I get back from holiday in a week. Not sure if there's much I can do if the crystal isn't the right frequency, but if it is stable then at least the calibration might work.
true :) Interesting idea exposing it in such a way that it can be calibrated by an external input. I'll have a think about that.
Sadly no (maybe on the L1?) - but it could go into flash along with the saved code. |
Beta Was this translation helpful? Give feedback.
-
Posted at 2015-08-28 by DrAzzy I thought you said that there was a tiny amount of non-volatile memory outside the normal flash on the STM32 chips? But in different places on different boards? |
Beta Was this translation helpful? Give feedback.
-
Posted at 2015-08-28 by asez73 Well, if it is not in some eeprom, maybe could it be just after the bootloader in flash page 0. After all, those calibration parameters are really not so often changed. If i remenber well, flash doesn't need to be erased if you just switch bits from 1 to 0 which allows to write once each byte valued $ff without erasing the whole relevant page. Padding the last bootloader page with $ff bytes could, somehow dangerously, allow to save hardware specific parameters in a safe place with respect to interpreter's versions... |
Beta Was this translation helpful? Give feedback.
-
Posted at 2015-09-07 by @gfwilliams
Sadly it's only nonvolatile if there's a battery connected - there's 64-80 bytes that survive a reset, but when power is disconnected it's gone.
Yes, for writing once that's definitely possible. It then gets dangerous trying to change the value though. Nothing stops the value being written alongside the saved code though... I think that would probably still be fine? I could make sure |
Beta Was this translation helpful? Give feedback.
-
Posted at 2015-08-27 by @gfwilliams
Does anyone know anything about the accuracy of crystals? I'm wondering whether 32kHz crystals are actually more accurate than 4Mhz ones... Having looked at Farnell it seems like the majority of them hover around the 20 parts per million range, but that sounds a bit strange to me.
The reason I'm looking into this is the Pico's timekeeping. At the moment it uses its internal low-speed oscillator for timekeeping, which seems to have a tolerance of around 100,000 parts per million :)
I'm considering going back to using the original (much more simple) timekeeping that uses the high speed oscillator, and then only using the low-speed oscillator to wake from Deep Sleep. It'd mean that the Pico's timekeeping would be properly accurate as long as it wasn't in Deep Sleep, and it might also mean I could do some calibration too.
Beta Was this translation helpful? Give feedback.
All reactions