Some sort of binary-chop mechanism should get the trimming done in just six iterations. I am expecting there will be little drift while doing that so should be good enough.
I don't see much use for the Always-On Timer in normal use because it only has millisecond resolution where others have microsecond resolution, but it is the only one which keeps running when everything else is powered down. I was thinking of doing the calibration just before powering down so any past drift is ignored, and any inaccuracy and drift which happens after being powered down is just tough luck.
My use case is being able to keep going on batteries while tracking time when briefly unplugged from USB, being moved from place to place, so I don't need accuracy but do want something better than what I appear to have.
The RP235X conveniently has ROSC and LPOSC values in OTP determined when it was programmed on the production line and that suggests I'm close to as bad as it could be for LPOSC. So I need to do something and I'd prefer it the best I can get it.
I don't see much use for the Always-On Timer in normal use because it only has millisecond resolution where others have microsecond resolution, but it is the only one which keeps running when everything else is powered down. I was thinking of doing the calibration just before powering down so any past drift is ignored, and any inaccuracy and drift which happens after being powered down is just tough luck.
My use case is being able to keep going on batteries while tracking time when briefly unplugged from USB, being moved from place to place, so I don't need accuracy but do want something better than what I appear to have.
The RP235X conveniently has ROSC and LPOSC values in OTP determined when it was programmed on the production line and that suggests I'm close to as bad as it could be for LPOSC. So I need to do something and I'd prefer it the best I can get it.
Code:
from machine import mem16def CheckOtpRecordedFrequency(row, expected, desc, si): otp = mem16[0x40130000 + row * 2] percent = ((otp - expected) * 100.0 ) / expected if percent < 0 : sign, percent = "-", -percent else : sign = "+" print("0x{:03X} {:<5} : {:,} {:<3}\tError is {:,} {:<3} {} {:5.2f}%".format( row, desc, otp, si, expected, si, sign, percent))print("{:04X}".format(mem16[0x40130006]), end = "")print("{:04X}".format(mem16[0x40130004]), end = "")print("{:04X}".format(mem16[0x40130002]), end = "")print("{:04X}".format(mem16[0x40130000]))CheckOtpRecordedFrequency(0x010, 11000, "ROSC", "kHz") # -60% / +80%CheckOtpRecordedFrequency(0x011, 32768, "LPOSC", "Hz") # -20% / +20%
Code:
C35DD24F15829A950x010 ROSC : 10,999 kHz Error is 11,000 kHz - 0.01%0x011 LPOSC : 26,842 Hz Error is 32,768 Hz - 18.08%
Statistics: Posted by hippy — Wed Nov 13, 2024 10:00 am