diff --git a/ports/stm32f4/common-hal/busio/UART.c b/ports/stm32f4/common-hal/busio/UART.c index c4ab237cd1..5ddfa6a4c7 100644 --- a/ports/stm32f4/common-hal/busio/UART.c +++ b/ports/stm32f4/common-hal/busio/UART.c @@ -250,10 +250,10 @@ size_t common_hal_busio_uart_read(busio_uart_obj_t *self, uint8_t *data, size_t } size_t rx_bytes = 0; - uint64_t start_ticks = ticks_ms; + uint64_t start_ticks = supervisor_ticks_ms64(); // Wait for all bytes received or timeout, same as nrf - while ( (ringbuf_count(&self->rbuf) < len) && (ticks_ms - start_ticks < self->timeout_ms) ) { + while ( (ringbuf_count(&self->rbuf) < len) && (supervisor_ticks_ms64() - start_ticks < self->timeout_ms) ) { RUN_BACKGROUND_TASKS; //restart if it failed in the callback if (errflag != HAL_OK) { diff --git a/ports/stm32f4/common-hal/microcontroller/__init__.c b/ports/stm32f4/common-hal/microcontroller/__init__.c index c7493a4d60..ffab5d1e50 100644 --- a/ports/stm32f4/common-hal/microcontroller/__init__.c +++ b/ports/stm32f4/common-hal/microcontroller/__init__.c @@ -48,9 +48,9 @@ STATIC uint32_t get_us(void) { uint32_t ticks_per_us = HAL_RCC_GetSysClockFreq()/1000000; uint32_t micros, sys_cycles; do { - micros = ticks_ms; + micros = supervisor_ticks_ms32(); sys_cycles = SysTick->VAL; //counts backwards - } while (micros != ticks_ms); //try again if ticks_ms rolled over + } while (micros != supervisor_ticks_ms32()); //try again if ticks_ms rolled over return (micros * 1000) + (ticks_per_us * 1000 - sys_cycles) / ticks_per_us; }