esp32 64-bit timer

akashdeepsingh
Posts: 9
Joined: Thu Feb 28, 2019 8:28 pm

esp32 64-bit timer

Postby akashdeepsingh » Tue Mar 05, 2019 6:32 am

Hi,

I am trying to write a program to:

1) start a timer
2) read its value at any time
3) multiply it by 12.5 to get time in nanoseconds.

I have modified the timer_group code. here's my app_main. I am trying to start my timer, read it fifty times and then print the results. I want to see how long does it take to fetch the value of the timer once:

Code: Select all

// timer configuration
    timer_config_t config;
    config.divider = TIMER_DIVIDER;
    config.counter_dir = TIMER_COUNT_UP;
    config.counter_en = TIMER_PAUSE;
    config.alarm_en = TIMER_ALARM_EN;
    config.intr_type = TIMER_INTR_LEVEL;
    config.auto_reload = 0;
    int timer_idx = TIMER_0;
    double timer_interval_sec = TIMER_INTERVAL0_SEC;

    // timer initialization using the config
    timer_init(TIMER_GROUP_0, timer_idx, &config);

    // start the timer
    timer_start(TIMER_GROUP_0, timer_idx);
    
    int i = 0;
    while (i<50){
        double timer_counter_value;
        timer_get_counter_value(TIMER_GROUP_0, timer_idx, &timer_counter_value);
        counter_array[i] = timer_counter_value;
        i = i + 1;
    }


    int j = 0;
    // print all the values stored in counter array
    for(j=0;j<50;j++){
        printf("Counter Value: %lld \n", counter_array[j]);
    }
However, I get all values as 0 in my output. I am doing something wrong?

Who is online

Users browsing this forum: Google [Bot] and 154 guests