esp32/machine_timer: Fix ESP32C3 timer period doubling.

The original ESP32 only supports timer source clock APB so it doesn't need
and doesn't have a clk_src field.

The ESP32C3 supports timer source clock APB and XTAL so it does have a
clk_src field, and this needs to be configured to get the correct period.

Fixes #8084.
This commit is contained in:
Brian Cooke 2022-11-18 13:40:05 +01:00 committed by Damien George
parent a67989aa20
commit 7fe7c55bb8
1 changed files with 3 additions and 0 deletions

View File

@ -189,6 +189,9 @@ STATIC void machine_timer_enable(machine_timer_obj_t *self) {
config.divider = TIMER_DIVIDER;
config.intr_type = TIMER_INTR_LEVEL;
config.counter_en = TIMER_PAUSE;
#if SOC_TIMER_GROUP_SUPPORT_XTAL
config.clk_src = TIMER_SRC_CLK_APB;
#endif
check_esp_err(timer_init(self->group, self->index, &config));
check_esp_err(timer_set_counter_value(self->group, self->index, 0x00000000));