diff options
| author | robert-hh <robert@hammelrath.com> | 2024-04-21 12:45:36 +0200 |
|---|---|---|
| committer | Damien George <damien@micropython.org> | 2024-09-06 17:16:44 +1000 |
| commit | ed86fdbdf6e2d3eb9a118d3476ce4c370ec48b06 (patch) | |
| tree | 8eadc0fed5dcc44c92617a21de5f858610a93814 | |
| parent | 3294606e2319dd64226434f20acc15b8869ddf55 (diff) | |
samd/mphalport: Fix an execution order bug in mp_hal_ticks_us_64().
The upper 32 bit of the 64 bit ticks register was taken before disabling
the interrupts. That may have caused a wrong return values. Besides that,
the function may cause trouble when called in an IRQ context, because it
unconditionally enables IRQ.
Signed-off-by: robert-hh <robert@hammelrath.com>
| -rw-r--r-- | ports/samd/mphalport.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/ports/samd/mphalport.c b/ports/samd/mphalport.c index 80904804c..3a33fdd6b 100644 --- a/ports/samd/mphalport.c +++ b/ports/samd/mphalport.c @@ -94,10 +94,10 @@ void mp_hal_delay_us(mp_uint_t us) { } uint64_t mp_hal_ticks_us_64(void) { - uint32_t us64_upper = ticks_us64_upper; uint32_t us64_lower; uint8_t intflag; __disable_irq(); + uint32_t us64_upper = ticks_us64_upper; #if defined(MCU_SAMD21) us64_lower = REG_TC4_COUNT32_COUNT; intflag = TC4->COUNT32.INTFLAG.reg; |
