Hardware Timer ESP32 Dev Module
Hardware timer, how to run once and restart again?
Videos
Guys
I have a DevKitC dev board, and I'm trying to set up a HW timer that I want to re-use under certain conditions. In other words, I don't want it to reload automatically, it should run once and then remain dormant until I enable it again. It seems to work the first time, but when I enable the timer a second time it fires immediately, without any delay. It seems I'm not resetting it properly, so that the counter starts from 0 again (?).
What I've tried is this:
initialize timer 0 in setup(), with a prescaler for 80MHz.
myTimer = timerBegin (0, 80, true); timerAttachInterrupt (myTimer, &isrMyTimer, true);
then when I want to use the timer I enable it as follows (for a duration of 3 seconds):
timerAlarmWrite(myTimer, 3000000), false); timerAlarmEnable(myTimer);
I am also trying to confirm the frequency to use for the timer, whether it is indeed 80MHz. I get the values as shown below for the different functions. Any thoughts on what they mean?
getCpuFrequencyMhz() 240 getXtalFrequencyMhz() 40 getApbFrequency() 80000000