me and friend were discussing what the most accurate way have an timer interrupt happen every second in RISC-V. We understand that the internal clock is generally inaccurate, but were still wondering what typically would be the most accurate way to do this, and we thought of reasons for both (assuming you set this immediately in your interrupt handler):
setting TIMECMP = TIMECMP + 1000
- you will incur minimal delay processing as it is simply a load+add+store
setting TIMECMP = TIME+1000
- if the interrupt is delayed but the clock stays true for some reason, this will drift less