Time adjustment using CF48
Posted: 09 Aug 2015, 17:19
Having not dived for a while I thought I should switch on my OSTC2C to check the battery voltage. The battery was fine but I found that the clock was over 20 minutes slow.
Rather than going through the time setting procedure I decided to use CF48 to slowly adjust the time forward until the correct time was displayed. I set CF48 to +2:00 and left it overnight. I checked the time on the OSTC2C the next day and found the clock was even slower than the previous day. I then experimented other values for CF48 and found that if it had a setting of +1:00 or more the clock lost time.
I copied the source .asm files from the OSTC repository and found the code that uses the value of CF48 to adjust the clock in isr.asm. Studying the logic between labels RTCisr2: and check_date: showed that time adjustment should work correctly for a negative value of CF48 or a positive value up to +0:59.
I would like to make some suggestions regarding modifying the code in this area as follows:
1. The initial check of the value of secs should check that it is greater than 59 seconds and return if not.
2. After the time_correction_value is copied to secs a loop should be created that tests the value of secs and increments mins and decrements secs by 60 until secs is less than 60.
Rather than going through the time setting procedure I decided to use CF48 to slowly adjust the time forward until the correct time was displayed. I set CF48 to +2:00 and left it overnight. I checked the time on the OSTC2C the next day and found the clock was even slower than the previous day. I then experimented other values for CF48 and found that if it had a setting of +1:00 or more the clock lost time.
I copied the source .asm files from the OSTC repository and found the code that uses the value of CF48 to adjust the clock in isr.asm. Studying the logic between labels RTCisr2: and check_date: showed that time adjustment should work correctly for a negative value of CF48 or a positive value up to +0:59.
I would like to make some suggestions regarding modifying the code in this area as follows:
1. The initial check of the value of secs should check that it is greater than 59 seconds and return if not.
2. After the time_correction_value is copied to secs a loop should be created that tests the value of secs and increments mins and decrements secs by 60 until secs is less than 60.