Open Abravius opened 2 years ago
I've this solution :
//Function used to correct the RTC clock
//<_Sign> : If the correction must be positive (false) or negative (true)
//<_Value> : Value to put in the register from 1 to 127.
void SetClockCorrection(bool _Sign, byte _Value)
{
RTC->MODE2.FREQCORR.reg = (byte)_Sign << 8 || _Value;
}
I'm testing it right now.
After 24 hours, same problem. I don't know why...
After 24 hours, same problem. I don't know why...
Your code shifts _Sign
one bit too far.
Furthermore, as far as I read the datasheet, there's need for write synchronization, thus you'll have to place something like
while(RTC->MODE2.STATUS.bit.SYNCBUSY);
before writing the register.
The RTC in my chip isn't really accurate. I think I'm not the only one
I looked in the library source code, but didn't find any existing function that allows correcting the clock.
I think it would be very important to add a function to correct the clock. This can be done using the
FREQCORR
" register.Datasheet:
https://cdn.sparkfun.com/datasheets/Dev/Arduino/Boards/Atmel-42181-SAM-D21_Datasheet.pdf
Register in the page 262.