Page 1 of 1

What is the proper way to use a timer?

Posted: Wed Oct 02, 2019 3:26 am
by azz-zza
Hello,
i want to perform a series of steps after a timer reached a certain value.
the documentation (https://docs.espressif.com/projects/esp ... api-alarms) states:
"...
After the alarm is enabled and the timer reaches the alarm value, depending on configuration, the following two actions may happen:
An interrupt will be triggered, if previously configured. See section Interrupts how to configure interrupts.
When auto_reload is enabled, the timer’s counter will be reloaded to start counting from specific initial value. The value to start should be set in advance with timer_set_counter_value().

"
Does it mean that the only way for me to detect the timer reaching a preset value, is through the interrupt triggered by an alarm?
And, if this assumption is correct, is it proper to call xEventGroupSetBitsFromISR from said alarm?

Thank you

Re: What is the proper way to use a timer?

Posted: Thu Oct 03, 2019 9:07 am
by username

Re: What is the proper way to use a timer?

Posted: Sat Oct 05, 2019 4:09 am
by azz-zza
well, but there is also https://github.com/espressif/esp-idf/tr ... /esp_timer

And what i is the difference, i'm not sure...

All im trying to achieve is to have an alarm raised without invoking an interrupt.

Re: What is the proper way to use a timer?

Posted: Sun Oct 06, 2019 4:14 am
by username
In the link you provided does not work off IRQ's. So if that is what you want you found it.

Re: What is the proper way to use a timer?

Posted: Sun Oct 06, 2019 5:40 pm
by azz-zza
username wrote:
Sun Oct 06, 2019 4:14 am
In the link you provided does not work off IRQ's. So if that is what you want you found it.
right, i'm trying to understand what is the difference ( other the use of interrupt) between these solutions? they use different API...

Re: What is the proper way to use a timer?

Posted: Mon Oct 07, 2019 2:06 pm
by Mr_Red
https://docs.espressif.com/projects/esp ... timer.html
Although FreeRTOS provides software timers, these timers have a few limitations:

Maximum resolution is equal to RTOS tick period
Timer callbacks are dispatched from a low-priority task

Hardware timers are free from both of the limitations, but often they are less convenient to use. For example, application components may need timer events to fire at certain times in the future, but the hardware timer only contains one “compare” value used for interrupt generation. This means that some facility needs to be built on top of the hardware timer to manage the list of pending events can dispatch the callbacks for these events as corresponding hardware interrupts happen.

Re: What is the proper way to use a timer?

Posted: Sat Oct 12, 2019 2:12 pm
by azz-zza
Mr_Red wrote:
Mon Oct 07, 2019 2:06 pm
https://docs.espressif.com/projects/esp ... timer.html
Although FreeRTOS provides software timers, these timers have a few limitations:

Maximum resolution is equal to RTOS tick period
Timer callbacks are dispatched from a low-priority task

Hardware timers are free from both of the limitations, but often they are less convenient to use. For example, application components may need timer events to fire at certain times in the future, but the hardware timer only contains one “compare” value used for interrupt generation. This means that some facility needs to be built on top of the hardware timer to manage the list of pending events can dispatch the callbacks for these events as corresponding hardware interrupts happen.

Oh.. thank you Mr_Red.. RTFM to me! //embarrassed