Code: Select all
0x4012a555: timer_ll_set_clock_prescale at /home/vendpago/esp/esp-idf/components/hal/esp32/include/hal/timer_ll.h:68
(inlined by) gptimer_select_periph_clock at /home/vendpago/esp/esp-idf/components/driver/gptimer.c:480
0x4012a8ab: gptimer_new_timer at /home/vendpago/esp/esp-idf/components/driver/gptimer.c:184 (discriminator 2)
0x400d9229: init_timer0 at /home/vendpago/esp/PayBluEsp/main/Timers.c:215
0x400d93e2: app_main_timer at /home/vendpago/esp/PayBluEsp/main/Timers.c:272 (discriminator 13)
Code: Select all
void init_timer0(){
ESP_LOGI(TAGtimer, "Create timer handle");
gptimer_handle_t gptimer0 = NULL;
gptimer_config_t timer_config = {
.clk_src = GPTIMER_CLK_SRC_APB,
.direction = GPTIMER_COUNT_UP,
.resolution_hz = 1000, // 1kHz, 1 tick=1ms
};
ESP_ERROR_CHECK(gptimer_new_timer(&timer_config, &gptimer0));
gptimer_event_callbacks_t cbs = {
.on_alarm = timer_group0_isr, // register user callback
};
ESP_ERROR_CHECK(gptimer_register_event_callbacks(gptimer0, &cbs, timer_queue));
ESP_ERROR_CHECK(gptimer_enable(gptimer0));
gptimer_alarm_config_t alarm_config = {
.reload_count = 0, // counter will reload with 0 on alarm event
.alarm_count = TIMER_INTERVAL0_SEC, // period = 1249ms @resolution 1kHz
.flags.auto_reload_on_alarm = true, // enable auto-reload
};
ESP_ERROR_CHECK(gptimer_set_alarm_action(gptimer0, &alarm_config));
ESP_ERROR_CHECK(gptimer_start(gptimer0));
}