Multiple timers using single hardware timer

giksonca
Posts: 17
Joined: Fri Sep 14, 2018 11:30 am

Multiple timers using single hardware timer

Postby giksonca » 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 ?. 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.

chegewara
Posts: 2364
Joined: Wed Jun 14, 2017 9:00 pm

Re: Multiple timers using single hardware timer

Postby chegewara » Wed Feb 06, 2019 6:55 pm

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.

ESP_Angus
Posts: 2344
Joined: Sun May 08, 2016 4:11 am

Re: Multiple timers using single hardware timer

Postby ESP_Angus » 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.

giksonca
Posts: 17
Joined: Fri Sep 14, 2018 11:30 am

Re: Multiple timers using single hardware timer

Postby giksonca » Thu Feb 07, 2019 5:02 am

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.

giksonca
Posts: 17
Joined: Fri Sep 14, 2018 11:30 am

Re: Multiple timers using single hardware timer

Postby giksonca » Thu Feb 21, 2019 6:18 am

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?

giksonca
Posts: 17
Joined: Fri Sep 14, 2018 11:30 am

Re: Multiple timers using single hardware timer

Postby giksonca » Mon Feb 25, 2019 8:26 am

Hi ESP_Angus

Any sample code available to create multiple timers from 64 bit timers. ?

Who is online

Users browsing this forum: Baidu [Spider], Bing [Bot] and 105 guests