feature request: faster than ms intervals
mark-hahn opened this issue · 2 comments
mark-hahn commented
I need an interrupt every 100 usecs. I assume this is no problem in esp-idf and should be possible in arduino. If needed it could support only 1 timer (direct from hw).
khoih-prog commented
Hi,
Thanks for your interest in the library.
The library already provides a way for you to do that with the function attachInterruptInterval()
// interval (in microseconds) and duration (in milliseconds). Duration = 0 or not specified => run indefinitely // No params and duration now. To be addes in the future by adding similar functions here or to esp32-hal-timer.c bool attachInterruptInterval(unsigned long interval, timer_callback callback);
So, to have the interrupt every 100 uS, just call
// interval (in microseconds)
#define TIMER0_INTERVAL_US 100
// Interval in microsecs
if (ITimer0.attachInterruptInterval(TIMER0_INTERVAL_US, TimerHandler0))
{
Serial.print(F("Starting ITimer0 OK, millis() = ")); Serial.println(millis());
}
else
Serial.println(F("Can't set ITimer0. Select another freq. or timer"));
Good Luck,
mark-hahn commented
Thanks