You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* There are several race conditions protected against:
104
-
* 1. TMR0 and TMR1 are both read at the same time, however, on rare occasions, one will have incremented before the other.
105
-
* Therefore we read both timer counters, and check if the middle 8 bits match, if they don't then read the counts again
106
-
* until they do. This ensures that one or the other counters are stable with respect to each other.
107
-
*
108
-
* 2. TMR1.CURCNT and Upper_count racing. Prevent this by disabling the TMR1 interrupt, which stops Upper_count increment interrupt (GP1CallbackFunction).
109
-
* Then check pending bit of TMR1 to see if we missed Upper_count interrupt, and add it manually later.
110
-
*
111
-
* 3. Race between the TMR1 pend, and the TMR1.CURCNT read. Even with TMR1 interrupt disabled, the pend bit
112
-
* may be set while TMR1.CURCNT is being read. We don't know if the pend bit matches the TMR1 state.
113
-
* To prevent this, the pending bit is read twice, and we see if it matches; if it doesn't, loop around again.
114
-
*
115
-
* Note the TMR1 interrupt is enabled on each iteration of the loop to flush out any pending TMR1 interrupt,
116
-
* thereby clearing any TMR1 pend's. This have no effect if this routine is called with interrupts globally disabled.
* There are several race conditions protected against:
104
+
* 1. TMR0 and TMR1 are both read at the same time, however, on rare occasions, one will have incremented before the other.
105
+
* Therefore we read both timer counters, and check if the middle 8 bits match, if they don't then read the counts again
106
+
* until they do. This ensures that one or the other counters are stable with respect to each other.
107
+
*
108
+
* 2. TMR1.CURCNT and Upper_count racing. Prevent this by disabling the TMR1 interrupt, which stops Upper_count increment interrupt (GP1CallbackFunction).
109
+
* Then check pending bit of TMR1 to see if we missed Upper_count interrupt, and add it manually later.
110
+
*
111
+
* 3. Race between the TMR1 pend, and the TMR1.CURCNT read. Even with TMR1 interrupt disabled, the pend bit
112
+
* may be set while TMR1.CURCNT is being read. We don't know if the pend bit matches the TMR1 state.
113
+
* To prevent this, the pending bit is read twice, and we see if it matches; if it doesn't, loop around again.
114
+
*
115
+
* Note the TMR1 interrupt is enabled on each iteration of the loop to flush out any pending TMR1 interrupt,
116
+
* thereby clearing any TMR1 pend's. This have no effect if this routine is called with interrupts globally disabled.
0 commit comments