As in esp_timer_esp32.c file ,esp_timer using uses FRC2 (legacy) timer of the ESP32 . and we can see those are hard coded to REG1(1) there as well.Is there more FRC timers which can be used for making multiple soft timers if we change accordingly ?. For example
In frc-timer_reg.h , #define FRC_TIMER_ALARM_REG(i) (REG_FRC_TIMER_BASE(i) + 0x10) // timer alarm value; register only present for i == 1
FRC_TIMER_ALARM_REG(1) is the only FRC timer can be used for alarm ? Also please provide some documentation on FRC timers.
FRC timer
Re: FRC timer
Please have a look at the Timer Group timers — they also provide alarm functionality, plus more flexible prescaler, and are 64-bit (so no need to handle overflows in software!).
FRC1 is a free-running counter without alarm functionality.
FRC2 is used for esp_timer. In fact, esp_timer uses FRC2 instead of the Timer Group timers so that users can have all 4 Timer Group timers to themselves! FRC2 is 32-bit and doesn't have any advantages over the TG timers.
FRC1 is a free-running counter without alarm functionality.
FRC2 is used for esp_timer. In fact, esp_timer uses FRC2 instead of the Timer Group timers so that users can have all 4 Timer Group timers to themselves! FRC2 is 32-bit and doesn't have any advantages over the TG timers.
Re: FRC timer
Thanks for the reply.
I had a look at TG group timers. But there is no sample code for multiple timer(soft timers) option using TG timer group as like in esp_timer. for example I would like to use TG timer 1 as base for multiple timer like in esp_timer (FRC2 as base). Is there any sample code available for the same implementation for TG ?
I had a look at TG group timers. But there is no sample code for multiple timer(soft timers) option using TG timer group as like in esp_timer. for example I would like to use TG timer 1 as base for multiple timer like in esp_timer (FRC2 as base). Is there any sample code available for the same implementation for TG ?
Re: FRC timer
No, there isn't any sample code for that. It's not too complex, however. You can start by maintaining a linked list (or an array) of timer objects, sorted by timeout time. Each time after changing something in the array, set the TG compare value to the expiry time of the first timer on the list. When an interrupt happens, walk through the list of timers one by one, checking which ones have expired. If the timer has expired, call the callback function, and proceed to the next one. If not expired yet, stop checking timeouts, and update TG compare value.
Who is online
Users browsing this forum: Majestic-12 [Bot] and 107 guests