Open jrahmeh opened 2 years ago
Even worse, the code does not actually provide the required guarantee, that after synchronization the two MTIME values are <1 count away from each other. Take this scenario:
I am not sure if "synchronized to within one MTIME tick period" means strictly-less-than-one tick, or just "less than two MTIME tick periods". If the former, the code should be fixed.
In the sample code for synchronizing MTIME registers, the code sequence for computing T3 does not match the comment. The comment says: "T3 = T1 - ((T0 + T2) / 2)". The code actually computes: "T3 = T1 - (T0/2 + T2/2)". For odd values in T0 and T2, these expressions produce different results. For example if T0 and T2 are both 3, then (T0+T2)/2 is 3, while (T0/2 + T2/2) is 2.