HOWTO Attach Interrupt Notes for Teensy boards The catch is your function is now part of an ISR (Interrupt Service Routine), and must be lean / mean, and follow certain rules. For example, certain function is blocking while it's connecting to WiFi or some services. That's necessary if you need to measure some data requiring better accuracy.įunctions using normal software timers, relying on loop() and calling millis(), won't work if the loop() or setup() is blocked by certain operation. Moreover, they are much more precise (certainly depending on clock frequency accuracy) than other software timers using millis() or micros(). These hardware timers, using interrupt, still work even if other functions are blocking. The correct choice is to use a Hardware Timer with Interrupt to call your function. You'd prefer to have your function called, no matter what happening with other functions (busy loop, bug, etc.). So your function might not be executed on-time or not at all, and the result would be disastrous. But what if another function is blocking the loop() or setup(). You normally use a software timer to poll, or even place the function in loop(). Imagine you have a system with a mission-critical function, measuring water level and control the sump pump or doing something much more important. Why using ISR-based Hardware Timer Interrupt is better Timers' interval is very long ( ulong millisecs). This library enables you to use Interrupt from Hardware Timers on supported Arduino boards such as AVR, Mega-AVR, ESP8266, ESP32, SAMD, SAM DUE, nRF52, STM32F/L/H/G/WB/MP1, Teensy, Nano-33-BLE, etc.Īs Hardware Timers are rare, and very precious assets of any board, this library now enables you to use up to 16 ISR-based Timers, while consuming only 1 Hardware Timer. Why do we need this TimerInterrupt_Generic library Features
0 Comments
Leave a Reply. |