0

For esp32 using Visual Studio Code, my requirement is when conditions are met - turn on the LED for two seconds. Reset then wait for the conditions to be met again (then turn on LED for two seconds).

I've successfully been able to start and disable the timer the first time the condition is met. Any subsequent time - this does not work.

Is there another way to do this? How can I get this to work?

  soundTimer=timerBegin(0,80,true);
  timerAttachInterrupt(soundTimer, &onTimer, true);
  timerAlarmWrite(soundTimer, 4000000, true);

inside ISR (to disable the timer repeating):

    timerEnd(soundTimer);

to trigger timer:

timerAlarmEnable(soundTimer);

I'm receiving these errors (via the Serial monitor):

40 E (75911) timer_group: timer_set_alarm(179): HW TIMER NEVER INIT ERROR

to which I haven't been able to find a resolution.

If hardware timer isn't the best approach - what should I be doing to reliably turn off the LED after two seconds?

3
  • 1
    a minimal reproducible example would probably help Commented Nov 27, 2024 at 8:34
  • As Alan mentioned, we can't help you without seeing your code, but also when you google for the error HW TIMER NEVER INIT ERROR then you find a bunch of relevant posts. Predictably, most of those hint that your timer hasn't been initialized. Commented Nov 27, 2024 at 15:26
  • Read the doc, there is a subtle difference between timerEnd() and timerStop(). timeStop can be restarted, while timerEnd would have to re-initialize Commented Nov 29, 2024 at 1:25

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.