summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrian Cooke <bdscooke@gmail.com>2022-11-18 13:40:05 +0100
committerDamien George <damien@micropython.org>2022-11-23 11:57:39 +1100
commit7fe7c55bb817c88981b1b237a8b4fa7762ff107a (patch)
tree4d5b1296f22b2f2dcb017959045c05404ac27cc8
parenta67989aa201817efaaefebdc7fd491358da45df8 (diff)
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.
-rw-r--r--ports/esp32/machine_timer.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/ports/esp32/machine_timer.c b/ports/esp32/machine_timer.c
index 83fe81f6e..c66cb2a48 100644
--- a/ports/esp32/machine_timer.c
+++ b/ports/esp32/machine_timer.c
@@ -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));