diff --git a/arch/xtensa/src/esp32/esp32_timerisr.c b/arch/xtensa/src/esp32/esp32_timerisr.c index 14f8a1cdfe..09653a582f 100644 --- a/arch/xtensa/src/esp32/esp32_timerisr.c +++ b/arch/xtensa/src/esp32/esp32_timerisr.c @@ -170,20 +170,15 @@ static int esp32_timerisr(int irq, uint32_t *regs) void xtensa_timer_initialize(void) { - uint64_t divisor; + uint32_t divisor; uint32_t count; /* Configured the timer0 as the system timer. * - * divisor = BOARD_CLOCK_FREQUENCY / ticks_per_sec - * = BOARD_CLOCK_FREQUENCY / (ticks_per_usec * 1000000) - * = (1000000 * BOARD_CLOCK_FREQUENCY) / ticks_per_usec - * - * A long long calculation is used to preserve accuracy in all cases. + * divisor = BOARD_CLOCK_FREQUENCY / ticks_per_sec */ - divisor = (1000000ull * (uint64_t)BOARD_CLOCK_FREQUENCY) / CONFIG_USEC_PER_TICK; - DEBUGASSERT(divisor <= UINT32_MAX); + divisor = BOARD_CLOCK_FREQUENCY / CLOCKS_PER_SEC; g_tick_divisor = divisor; /* Set up periodic timer */ diff --git a/configs/esp32-core/include/board.h b/configs/esp32-core/include/board.h index e3b2e85a87..fb0c327482 100644 --- a/configs/esp32-core/include/board.h +++ b/configs/esp32-core/include/board.h @@ -56,7 +56,9 @@ #if 0 # define BOARD_CLOCK_FREQUENCY 80000000 #else -# define BOARD_CLOCK_FREQUENCY BOARD_XTAL_FREQUENCY + /* Hmmm... actually appears to be running at about 2 x the XTAL frequency */ + +# define BOARD_CLOCK_FREQUENCY (2 * BOARD_XTAL_FREQUENCY) #endif #endif /* __CONFIGS_ESP32_CORE_INCLUDE_BOARD_H */