Skip to content

Commit

Permalink
Handle better 160MHz cpu clock
Browse files Browse the repository at this point in the history
  • Loading branch information
me-no-dev committed Dec 18, 2018
1 parent 66d33f7 commit 3e66aef
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions cores/esp32/esp32-hal-misc.c
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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)
Expand Down

0 comments on commit 3e66aef

Please sign in to comment.