gptimer config error on .clk_src

joaomanfroi
Posts: 2
Joined: Wed Sep 28, 2022 2:08 pm

gptimer config error on .clk_src

Postby joaomanfroi » Tue Dec 20, 2022 1:25 pm

Hi, I've update my code from ESP-IDF 4.3 to 5.0 and one of the thigs that changed was the general purpose timer, I'm trying to use the timer on a custom project, it builds and flash but when I turn on the board I get this error on the monitor.

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)
this is the code for the init_timer0:

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));
}
I tried to use the example code from the GPTIMER and it works flawlessly.

Who is online

Users browsing this forum: No registered users and 248 guests