Electronics > Microcontrollers

ESP32 timers

(1/2) > >>

HwAoRrDk:
Am I correct in thinking that the ESP32 timer peripheral has no integration with GPIO?

As far as I can tell, when a timer counter match (or "alarm" in their terminology) occurs, it can only trigger an interrupt. So you can't, for example, have a GPIO pin toggled in hardware on counter match?

One thing I am looking to do is to use a one-shot timer to implement an output pulse of a few hundred milliseconds on a GPIO pin with as little software involvement as possible. So far, as mentioned above, I don't think I can have a purely hardware-based solution. What are my alternatives?

From my research, other potential solutions seem to be:


* Simple delay - undesirable as it's not asynchronous
* ESP-IDF GPTimer API
* ESP-IDF High-Resolution Timer API
From reading the docs, it seems to me that the High-Resolution Timer API is basically an abstraction that allows multiple timers on top of a single hardware timer with a fixed 1 usec timebase. Whereas the GPTimer is more flexible, essentially a wrapper around the hardware timer peripheral.

One thing I would particularly like to have is to ensure with as much certainty as possible that the output pulse will be turned off after the desired period. What guarantees do these APIs provide that the callback function will be run when the timer alarm is triggered?

lucazader:
If you are wanting to toggle a pin for pwm reasons. the ESP32 does have a separate PWM peripheral.
See sections 4.1.15 and 4.1.16 of the data sheet. and also here for some examples: https://github.com/espressif/esp-idf/tree/master/examples/peripherals/mcpwm

HwAoRrDk:
Oh, you can use the PWM peripheral for such a one-shot pulse output?

Didn't think about that. Thanks, I will have to look into that. :-+

Does it allow you to use an arbitrary GPIO pin?

HwAoRrDk:
Hmm, I'm not seeing that there's any possible way of having a single-shot output pulse using the MCPWM peripheral (whether through ESP-IDF API or bare metal)... :-//

florian-x:
The RMT peripheral should be able to produce a one-off pulse, I'd say...
https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-reference/peripherals/rmt.html

Navigation

[0] Message Index

[#] Next page

There was an error while thanking
Thanking...
Go to full version