Peripheral Timer eventually returning unexpected count
Posted: Fri Jan 15, 2021 11:12 pm
ESP-WROOM-32
"ESP32 DEVKITV1" board
Hi!
I´m about to develop an application that is time-critical and demands a reasonable precision on timer count.
It´s a simple code that should register how many timer counts occur between two positive edges on square wave signal. I´m using a pretty stable 1KHz square wave generator.
Considering a divider with value 40, it´s expected something around 2000 counts, but I´ve detected a random timer count variation around half of the correct average value.
timer_config_t config0 = {
.alarm_en = false,
.counter_en = false,
.intr_type = TIMER_INTR_LEVEL,
.counter_dir = TIMER_COUNT_UP,
.auto_reload = false,
.divider = 40
};
Interrupt routine for a certain GPIO on positive transition works perfectly. It never miss a rising edge, never is called when it should not be. When the GPIO interrupt occurs, timer is paused, its value is read and spared and finally timer is started.
Can somebody give me some clue?
"ESP32 DEVKITV1" board
Hi!
I´m about to develop an application that is time-critical and demands a reasonable precision on timer count.
It´s a simple code that should register how many timer counts occur between two positive edges on square wave signal. I´m using a pretty stable 1KHz square wave generator.
Considering a divider with value 40, it´s expected something around 2000 counts, but I´ve detected a random timer count variation around half of the correct average value.
timer_config_t config0 = {
.alarm_en = false,
.counter_en = false,
.intr_type = TIMER_INTR_LEVEL,
.counter_dir = TIMER_COUNT_UP,
.auto_reload = false,
.divider = 40
};
Interrupt routine for a certain GPIO on positive transition works perfectly. It never miss a rising edge, never is called when it should not be. When the GPIO interrupt occurs, timer is paused, its value is read and spared and finally timer is started.
Can somebody give me some clue?