Page 1 of 1
Multiple timers using single hardware timer
Posted: Wed Feb 06, 2019 1:16 pm
by giksonca
Hi
Is there any sample code available for Multiple timer implementation using a single HW timer as base ?. For example i will be using same hardware timer for UART TX & RX with divided frequency. This will help when 4 HW timers are running out.
Re: Multiple timers using single hardware timer
Posted: Wed Feb 06, 2019 6:55 pm
by chegewara
esp32 is having 4 HW timers. All timers are divided into 2 groups, 2 timers in each group. Each HW timer can have its own independent configuration.
Re: Multiple timers using single hardware timer
Posted: Wed Feb 06, 2019 10:05 pm
by ESP_Angus
giksonca wrote: ↑Wed Feb 06, 2019 1:16 pm
Hi
Is there any sample code available for Multiple timer implementation using a single HW timer as base ?.
Yes! This is a common enough requirement that a high resolution timer abstraction is available in ESP-IDF:
https://docs.espressif.com/projects/esp ... timer.html
There is an example in examples/system/esp_timer directory of ESP-IDF.
For example i will be using same hardware timer for UART TX & RX with divided frequency. This will help when 4 HW timers are running out.
Do you mean that you need to use the timer to do something with the UART peripheral, or do you plan to do "software serial"? The latter may not be necessary, the ESP32 has 3 hardware UARTs and each UART can be remapped to any pair of GPIOs. Check out the uart driver for full details.
Re: Multiple timers using single hardware timer
Posted: Thu Feb 07, 2019 5:02 am
by giksonca
ESP_Angus wrote: ↑Wed Feb 06, 2019 10:05 pm
giksonca wrote: ↑Wed Feb 06, 2019 1:16 pm
Hi
Is there any sample code available for Multiple timer implementation using a single HW timer as base ?.
Yes! This is a common enough requirement that a high resolution timer abstraction is available in ESP-IDF:
https://docs.espressif.com/projects/esp ... timer.html
There is an example in examples/system/esp_timer directory of ESP-IDF.
For example i will be using same hardware timer for UART TX & RX with divided frequency. This will help when 4 HW timers are running out.
Do you mean that you need to use the timer to do something with the UART peripheral, or do you plan to do "software serial"? The latter may not be necessary, the ESP32 has 3 hardware UARTs and each UART can be remapped to any pair of GPIOs. Check out the uart driver for full details.
Thank you very much.I was referring examples/peripherals/Timer_group. I was not aware about examples/system/esp_timer. I will look into that. Yes. I am trying to create RX & TX timers for controlling UART interface. It will be good if I can use same HW timer for both.
Re: Multiple timers using single hardware timer
Posted: Thu Feb 21, 2019 6:18 am
by giksonca
esp_ timer (example/system/esp_timer) is entirely different compared to 64 bit timer group (2 groups with 4 timers) . Is there any sample code available to create multiple timers from any of these 64 bit timers as base ?.
If we are looking on STM32 based chips there are capture/compare registers with each Hardware timers which is helpful for creating multiple timers with different time intervals.Is there any similar registers in ESP32 64 bit timer?
Re: Multiple timers using single hardware timer
Posted: Mon Feb 25, 2019 8:26 am
by giksonca
Hi ESP_Angus
Any sample code available to create multiple timers from 64 bit timers. ?