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?
Peripheral Timer eventually returning unexpected count
Re: Peripheral Timer eventually returning unexpected count
Can you share more of your code? Are you using an interrupt function triggered by the counter pulse?
What does ".counter_en = false " do?.
It's 1kHz, 40 divider, why do you expect 2000 counts? Is it run for 80 seconds?
What does ".counter_en = false " do?.
It's 1kHz, 40 divider, why do you expect 2000 counts? Is it run for 80 seconds?
Re: Peripheral Timer eventually returning unexpected count
Hi, Becorey.
"Are you using an interrupt function triggered by the counter pulse?"
sraposo > that´s triggered by positive transition of the signal from external oscillator.
"What does ".counter_en = false " do?."
sraposo > That means counter will not work till a "timer_start" is called.
"It's 1kHz, 40 divider, why do you expect 2000 counts? Is it run for 80 seconds?"
sraposo > Timer clock operates at 80MHz, so a 0,0000000125s period. A divider with a value 40 makes counter steps each 500ns.
"Are you using an interrupt function triggered by the counter pulse?"
sraposo > that´s triggered by positive transition of the signal from external oscillator.
"What does ".counter_en = false " do?."
sraposo > That means counter will not work till a "timer_start" is called.
"It's 1kHz, 40 divider, why do you expect 2000 counts? Is it run for 80 seconds?"
sraposo > Timer clock operates at 80MHz, so a 0,0000000125s period. A divider with a value 40 makes counter steps each 500ns.
Who is online
Users browsing this forum: No registered users and 89 guests