khoih-prog / TimerInterrupt

This library enables you to use Interrupt from Hardware Timers on an Arduino, such as Nano, UNO, Mega, etc. It now supports 16 ISR-based timers, while consuming only 1 hardware Timer. Timers' interval is very long (ulong millisecs). The most important feature is they're ISR-based timers. Therefore, their executions are not blocked by bad-behaving functions or tasks. This important feature is absolutely necessary for mission-critical tasks.
MIT License
98 stars 11 forks source link

Several intervals based on the same hardware timer - how to use? #4

Closed vorlovsky closed 4 years ago

vorlovsky commented 4 years ago

Hi!

It's not clear how the one can instantiate and use several timers based on a single hardware timer. I've checked the given examples and searched over the internet, but it's the same info available everywhere. All the examples seems to represent the same approach: init e.g. ITimer1, then attachInterruptInterval to it, in case the second timer is needed - ITimer2 goes through the same process, and that's all. As I understand, these two instances use different HW timers and so I have no idea how up to 16(!) timers can be attached/detached this way.

Please, help.

BR, Vyacheslav

khoih-prog commented 4 years ago

@vorlovsky

Thanks for using the library.

Please have a look at New from v102 and example ISR_Timer_Complex.

The ISR_Timer_Complex example demontrates the usage of 4 ISR-timers using just ITimer1.

You can use max 16 timers for each HW ITimer.