From 3e66aeff84d4e2a633b9fb5394d25e78bf9cbc5e Mon Sep 17 00:00:00 2001 From: me-no-dev Date: Tue, 18 Dec 2018 22:04:02 +0100 Subject: [PATCH] Handle better 160MHz cpu clock --- cores/esp32/esp32-hal-misc.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cores/esp32/esp32-hal-misc.c b/cores/esp32/esp32-hal-misc.c index 642949d7..5a6e64b9 100644 --- a/cores/esp32/esp32-hal-misc.c +++ b/cores/esp32/esp32-hal-misc.c @@ -66,7 +66,7 @@ uint32_t cpuFrequencyGet(){ unsigned long IRAM_ATTR micros() { - return (unsigned long) (esp_timer_get_time() * (240 / _cpu_freq_mhz)); + return (unsigned long) ((esp_timer_get_time() * 240) / _cpu_freq_mhz); } unsigned long IRAM_ATTR millis() @@ -76,7 +76,7 @@ unsigned long IRAM_ATTR millis() void delay(uint32_t ms) { - vTaskDelay(ms / portTICK_PERIOD_MS / (240 / _cpu_freq_mhz)); + vTaskDelay((ms * _cpu_freq_mhz) / (portTICK_PERIOD_MS * 240)); } void IRAM_ATTR delayMicroseconds(uint32_t us)