You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Jan 29, 2023. It is now read-only.
This library enables you to use Interrupt from Hardware Timers on an STM32-based board, such as STM32F/L/H/G/WB/MP1.
As 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. Timers' interval is very long (ulong millisecs).
Now with these new 16 ISR-based timers, the maximum interval is practically unlimited (limited only by unsigned long milliseconds) while the accuracy is nearly perfect compared to software timers.
The most important feature is they're ISR-based timers. Therefore, their executions are not blocked by bad-behaving functions / tasks. This important feature is absolutely necessary for mission-critical tasks.
The ISR_Timer_Complex example will demonstrate the nearly perfect accuracy compared to software timers by printing the actual elapsed millisecs of each type of timers.
Being ISR-based timers, their executions are not blocked by bad-behaving functions / tasks, such as connecting to WiFi, Internet and Blynk services. You can also have many (up to 16) timers to use.
This non-being-blocked important feature is absolutely necessary for mission-critical tasks.
You'll see blynkTimer Software is blocked while system is connecting to WiFi / Internet / Blynk, as well as by blocking task
in loop(), using delay() function as an example. The elapsed time then is very unaccurate
Why using ISR-based Hardware Timer Interrupt is better
Imagine you have a system with a mission-critical function, measuring water level and control the sump pump or doing something much more important. You normally use a software timer to poll, or even place the function in loop(). But what if another function is blocking the loop() or setup().
So your function might not be executed, and the result would be disastrous.
You'd prefer to have your function called, no matter what happening with other functions (busy loop, bug, etc.).
The correct choice is to use a Hardware Timer with Interrupt to call your function.
These hardware timers, using interrupt, still work even if other functions are blocking. Moreover, they are much more precise (certainly depending on clock frequency accuracy) than other software timers using millis() or micros(). That's necessary if you need to measure some data requiring better accuracy.
Functions using normal software timers, relying on loop() and calling millis(), won't work if the loop() or setup() is blocked by certain operation. For example, certain function is blocking while it's connecting to WiFi or some services.
The catch is your function is now part of an ISR (Interrupt Service Routine), and must be lean / mean, and follow certain rules. More to read on:
All STM32 boards (STM32F/L/H/G/WB/MP1) with 32K+ Flash, with Built-in Ethernet
STM32F/L/H/G/WB/MP1 boards (with 32+K Flash) running W5x00 or ENC28J60 shields)
Nucleo-144
Nucleo-64
Discovery
Generic STM32F0, STM32F1, STM32F2, STM32F3, STM32F4, STM32F7 (with 64+K Flash): x8 and up
STM32L0, STM32L1, STM32L4, STM32L5
STM32G0, STM32G4
STM32H7
STM32WB
STM32MP1
LoRa boards
3-D printer boards
Generic Flight Controllers
Midatronics boards
Important Notes about ISR
Inside the attached function, delay() won't work and the value returned by millis() will not increment. Serial data received while in the function may be lost. You should declare as volatile any variables that you modify within the attached function.
Typically global variables are used to pass data between an ISR and the main program. To make sure variables shared between an ISR and the main program are updated correctly, declare them as volatile.
The best and easiest way is to use Arduino Library Manager. Search for STM32_TimerInterrupt, then select / install the latest version.
You can also use this link for more detailed instructions.
Use included platformio.ini file from examples to ensure that all dependent libraries will installed automatically. Please visit documentation for the other options and examples at Project Configuration File
Libraries' Patches
Notes: These patches are totally optional and necessary only when you use the related Ethernet library and get certain error or issues.
1. For application requiring 2K+ HTML page
If your application requires 2K+ HTML page, the current Ethernet library must be modified if you are using W5200/W5500 Ethernet shields. W5100 is not supported for 2K+ buffer. If you use boards requiring different CS/SS pin for W5x00 Ethernet shield, for example ESP32, ESP8266, nRF52, etc., you also have to modify the following libraries to be able to specify the CS/SS pin correctly.
To be able to compile and run on nRF52 boards with ENC28J60 using UIPEthernet library, you have to copy these following files into the UIPEthernet utility directory to overwrite the old files:
To fix ESP32 compile error, just copy the following file into the ESP32 cores/esp32 directory (e.g. ./arduino-1.8.12/hardware/espressif/cores/esp32) to overwrite the old file:
8. For STM32 core F3 and F4 using UIPEthernet library
Check if you need to install the UIPEthernet patch new STM32 core F3/F4 compatibility to avoid errors #include HardwareSPI.h on some STM32 boards (Nucleo-32 F303K8, etc.)
HOWTO Fix Multiple Definitions Linker Error
The current library implementation, using xyz-Impl.h instead of standard xyz.cpp, possibly creates certain Multiple Definitions Linker error in certain use cases.
in many files. But be sure to use the following #include in just 1 .h, .cpp or .ino file, which must not be included in any other file, to avoid Multiple Definitions Linker Error
// To be included only in main(), .ino with setup() to avoid `Multiple Definitions` Linker Error #include<STM32_ISR_Timer.h>//https://github.com/khoih-prog/STM32_TimerInterrupt
More useful Information about STM32 Timers
The Timers of STM32s are numerous, yet very sophisticated and powerful.
In general, across the STM32 microcontrollers families, the timer peripherals that have the same name also have the same features set, but there are a few exceptions.
For example, the TIM1 timer peripheral is shared across the STM32F1 Series, STM32F2 Series and STM32F4 Series, but for the specific case of STM32F30x microcontrollers family, the TIM1 timer peripheral features a bit richer features set than the TIM1 present in the other families.
The general purpose timers embedded by the STM32 microcontrollers share the same backbone structure; they differ only on the level of features embedded by a given timer peripheral.
The level of features integration for a given timer peripheral is decided based on the applications field that it targets.
The timer peripherals can be classified as:
* Advanced-configuration timers like TIM1 and TIM8 among others.
* General-purpose configuration timers like TIM2 and TIM3 among others
* Lite-configuration timers like TIM9, TIM10, TIM12 and TIM16 among others
* Basic-configuration timers like TIM6 and TIM7 among others.
For example, STM32F103C8T6 has one advance timer, while STM32F103VET6 has two advanced timers. Nucleo-144 STM32F767ZI boards have 14 Timers, TIM1-TIM14.
To be sure which Timer is available for the board you're using, check the Core Package's related files. For example, for Nucleo-144 STM32F767ZI, check these files:
Now with these new 16 ISR-based timers (while consuming only 1 hardware timer), the maximum interval is practically unlimited (limited only by unsigned long milliseconds). The accuracy is nearly perfect compared to software timers. The most important feature is they're ISR-based timers Therefore, their executions are not blocked by bad-behaving functions / tasks.
This important feature is absolutely necessary for mission-critical tasks.
The ISR_Timer_Complex example will demonstrate the nearly perfect accuracy compared to software timers by printing the actual elapsed millisecs of each type of timers.
Being ISR-based timers, their executions are not blocked by bad-behaving functions / tasks, such as connecting to WiFi, Internet and Blynk services. You can also have many (up to 16) timers to use.
This non-being-blocked important feature is absolutely necessary for mission-critical tasks.
You'll see blynkTimer Software is blocked while system is connecting to WiFi / Internet / Blynk, as well as by blocking task
in loop(), using delay() function as an example. The elapsed time then is very unaccurate
Usage
Before using any Timer, you have to make sure the Timer has not been used by any other purpose.
// In STM32, avoid doing something fancy in ISR, for example complex Serial.print with String() argument // The pure simple Serial.prints here are just for demonstration and testing. Must be eliminate in working environment // Or you can get this run-time error / crash voiddoingSomething2s() { // Doing something here inside ISR }
voiddoingSomething5s() { // Doing something here inside ISR }
voiddoingSomething11s() { // Doing something here inside ISR }
voiddoingSomething101s() { // Doing something here inside ISR }
voidsetup() { ....
// Interval in microsecs if (ITimer.attachInterruptInterval(HW_TIMER_INTERVAL_US, TimerHandler)) { lastMillis = millis(); Serial.println("Starting ITimer OK, millis() = " + String(lastMillis)); } else Serial.println("Can't set ITimer correctly. Select another freq. or interval");
// Just to demonstrate, don't use too many ISR Timers if not absolutely necessary // You can use up to 16 timer for each ISR_Timer ISR_Timer.setInterval(TIMER_INTERVAL_2S, doingSomething2s); ISR_Timer.setInterval(TIMER_INTERVAL_5S, doingSomething5s); ISR_Timer.setInterval(TIMER_INTERVAL_11S, doingSomething11s); ISR_Timer.setInterval(TIMER_INTERVAL_101S, doingSomething101s); }
0. Only for special ISR debugging only. Can hang the system.
// Don't define TIMER_INTERRUPT_DEBUG > 2. Only for special ISR debugging only. Can hang the system.
#define TIMER_INTERRUPT_DEBUG 0
#define _TIMERINTERRUPT_LOGLEVEL_ 3
#include "STM32TimerInterrupt.h"
// To be included only in main(), .ino with setup() to avoid `Multiple Definitions` Linker Error
#include "STM32_ISR_Timer.h"
#include // https://github.com/jfturcot/SimpleTimer
#ifndef LED_BUILTIN
#define LED_BUILTIN 13
#endif
#ifndef LED_BLUE
#define LED_BLUE 2
#endif
#ifndef LED_RED
#define LED_RED 3
#endif
#define HW_TIMER_INTERVAL_US 10000L
volatile uint32_t startMillis = 0;
// Depending on the board, you can select STM32 Hardware Timer from TIM1-TIM22
// For example, F767ZI can select Timer from TIM1-TIM14
// If you select a Timer not correctly, you'll get a message from ci[ompiler
// 'TIMxx' was not declared in this scope; did you mean 'TIMyy'?
// Init STM32 timer TIM1
STM32Timer ITimer(TIM1);
// Init STM32_ISR_Timer
// Each STM32_ISR_Timer can service 16 different ISR-based timers
STM32_ISR_Timer ISR_Timer;
#define LED_TOGGLE_INTERVAL_MS 2000L
void TimerHandler()
{
static bool toggle = false;
static int timeRun = 0;
ISR_Timer.run();
// Toggle LED every LED_TOGGLE_INTERVAL_MS = 2000ms = 2s
if (++timeRun == ((LED_TOGGLE_INTERVAL_MS * 1000) / HW_TIMER_INTERVAL_US) )
{
timeRun = 0;
//timer interrupt toggles pin LED_BUILTIN
digitalWrite(LED_BUILTIN, toggle);
toggle = !toggle;
}
}
/////////////////////////////////////////////////
#define NUMBER_ISR_TIMERS 16
typedef void (*irqCallback) ();
/////////////////////////////////////////////////
#define USE_COMPLEX_STRUCT true
#if USE_COMPLEX_STRUCT
typedef struct
{
irqCallback irqCallbackFunc;
uint32_t TimerInterval;
unsigned long deltaMillis;
unsigned long previousMillis;
} ISRTimerData;
// In NRF52, avoid doing something fancy in ISR, for example Serial.print()
// The pure simple Serial.prints here are just for demonstration and testing. Must be eliminate in working environment
// Or you can get this run-time error / crash
void doingSomething(int index);
#else
volatile unsigned long deltaMillis [NUMBER_ISR_TIMERS] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
volatile unsigned long previousMillis [NUMBER_ISR_TIMERS] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
// You can assign any interval for any timer here, in milliseconds
uint32_t TimerInterval[NUMBER_ISR_TIMERS] =
{
5000L, 10000L, 15000L, 20000L, 25000L, 30000L, 35000L, 40000L,
45000L, 50000L, 55000L, 60000L, 65000L, 70000L, 75000L, 80000L
};
void doingSomething(int index)
{
unsigned long currentMillis = millis();
deltaMillis[index] = currentMillis - previousMillis[index];
previousMillis[index] = currentMillis;
}
#endif
////////////////////////////////////
// Shared
////////////////////////////////////
void doingSomething0()
{
doingSomething(0);
}
void doingSomething1()
{
doingSomething(1);
}
void doingSomething2()
{
doingSomething(2);
}
void doingSomething3()
{
doingSomething(3);
}
void doingSomething4()
{
doingSomething(4);
}
void doingSomething5()
{
doingSomething(5);
}
void doingSomething6()
{
doingSomething(6);
}
void doingSomething7()
{
doingSomething(7);
}
void doingSomething8()
{
doingSomething(8);
}
void doingSomething9()
{
doingSomething(9);
}
void doingSomething10()
{
doingSomething(10);
}
void doingSomething11()
{
doingSomething(11);
}
void doingSomething12()
{
doingSomething(12);
}
void doingSomething13()
{
doingSomething(13);
}
void doingSomething14()
{
doingSomething(14);
}
void doingSomething15()
{
doingSomething(15);
}
#if USE_COMPLEX_STRUCT
ISRTimerData curISRTimerData[NUMBER_ISR_TIMERS] =
{
//irqCallbackFunc, TimerInterval, deltaMillis, previousMillis
{ doingSomething0, 5000L, 0, 0 },
{ doingSomething1, 10000L, 0, 0 },
{ doingSomething2, 15000L, 0, 0 },
{ doingSomething3, 20000L, 0, 0 },
{ doingSomething4, 25000L, 0, 0 },
{ doingSomething5, 30000L, 0, 0 },
{ doingSomething6, 35000L, 0, 0 },
{ doingSomething7, 40000L, 0, 0 },
{ doingSomething8, 45000L, 0, 0 },
{ doingSomething9, 50000L, 0, 0 },
{ doingSomething10, 55000L, 0, 0 },
{ doingSomething11, 60000L, 0, 0 },
{ doingSomething12, 65000L, 0, 0 },
{ doingSomething13, 70000L, 0, 0 },
{ doingSomething14, 75000L, 0, 0 },
{ doingSomething15, 80000L, 0, 0 }
};
void doingSomething(int index)
{
unsigned long currentMillis = millis();
curISRTimerData[index].deltaMillis = currentMillis - curISRTimerData[index].previousMillis;
curISRTimerData[index].previousMillis = currentMillis;
}
#else
irqCallback irqCallbackFunc[NUMBER_ISR_TIMERS] =
{
doingSomething0, doingSomething1, doingSomething2, doingSomething3,
doingSomething4, doingSomething5, doingSomething6, doingSomething7,
doingSomething8, doingSomething9, doingSomething10, doingSomething11,
doingSomething12, doingSomething13, doingSomething14, doingSomething15
};
#endif
///////////////////////////////////////////
#define SIMPLE_TIMER_MS 2000L
// Init SimpleTimer
SimpleTimer simpleTimer;
// Here is software Timer, you can do somewhat fancy stuffs without many issues.
// But always avoid
// 1. Long delay() it just doing nothing and pain-without-gain wasting CPU power.Plan and design your code / strategy ahead
// 2. Very long "do", "while", "for" loops without predetermined exit time.
void simpleTimerDoingSomething2s()
{
static unsigned long previousMillis = startMillis;
unsigned long currMillis = millis();
Serial.print(F("SimpleTimer : ")); Serial.print(SIMPLE_TIMER_MS / 1000);
Serial.print(F(", ms : ")); Serial.print(currMillis);
Serial.print(F(", Dms : ")); Serial.println(currMillis - previousMillis);
for (uint16_t i = 0; i < NUMBER_ISR_TIMERS; i++)
{
#if USE_COMPLEX_STRUCT
Serial.print(F("Timer : ")); Serial.print(i);
Serial.print(F(", programmed : ")); Serial.print(curISRTimerData[i].TimerInterval);
Serial.print(F(", actual : ")); Serial.println(curISRTimerData[i].deltaMillis);
#else
Serial.print(F("Timer : ")); Serial.print(i);
Serial.print(F(", programmed : ")); Serial.print(TimerInterval[i]);
Serial.print(F(", actual : ")); Serial.println(deltaMillis[i]);
#endif
}
previousMillis = currMillis;
}
void setup()
{
pinMode(LED_BUILTIN, OUTPUT);
Serial.begin(115200);
while (!Serial);
delay(100);
Serial.print(F("\nStarting ISR_16_Timers_Array_Complex on ")); Serial.println(BOARD_NAME);
Serial.println(STM32_TIMER_INTERRUPT_VERSION);
Serial.print(F("CPU Frequency = ")); Serial.print(F_CPU / 1000000); Serial.println(F(" MHz"));
// Interval in microsecs
if (ITimer.attachInterruptInterval(HW_TIMER_INTERVAL_US, TimerHandler))
{
startMillis = millis();
Serial.print(F("Starting ITimer OK, millis() = ")); Serial.println(startMillis);
}
else
Serial.println(F("Can't set ITimer correctly. Select another freq. or interval"));
// Just to demonstrate, don't use too many ISR Timers if not absolutely necessary
// You can use up to 16 timer for each STM32_ISR_Timer
for (uint16_t i = 0; i < NUMBER_ISR_TIMERS; i++)
{
#if USE_COMPLEX_STRUCT
curISRTimerData[i].previousMillis = startMillis;
ISR_Timer.setInterval(curISRTimerData[i].TimerInterval, curISRTimerData[i].irqCallbackFunc);
#else
previousMillis[i] = startMillis;
ISR_Timer.setInterval(TimerInterval[i], irqCallbackFunc[i]);
#endif
}
// You need this timer for non-critical tasks. Avoid abusing ISR if not absolutely necessary.
simpleTimer.setInterval(SIMPLE_TIMER_MS, simpleTimerDoingSomething2s);
}
#define BLOCKING_TIME_MS 10000L
void loop()
{
// This unadvised blocking task is used to demonstrate the blocking effects onto the execution and accuracy to Software timer
// You see the time elapse of ISR_Timer still accurate, whereas very unaccurate for Software Timer
// The time elapse for 2000ms software timer now becomes 3000ms (BLOCKING_TIME_MS)
// While that of ISR_Timer is still prefect.
delay(BLOCKING_TIME_MS);
// You need this Software timer for non-critical tasks. Avoid abusing ISR if not absolutely necessary
// You don't need to and never call ISR_Timer.run() here in the loop(). It's already handled by ISR timer.
simpleTimer.run();
}">#if !( defined(STM32F0) || defined(STM32F1) || defined(STM32F2) || defined(STM32F3) ||defined(STM32F4) || defined(STM32F7) || \ defined(STM32L0) || defined(STM32L1) || defined(STM32L4) || defined(STM32H7) ||defined(STM32G0) || defined(STM32G4) || \ defined(STM32WB) || defined(STM32MP1) || defined(STM32L5) ) #error This code is designed to run on STM32F/L/H/G/WB/MP1 platform! Please check your Tools->Board setting. #endif
// These define's must be placed at the beginning before #include "STM32TimerInterrupt.h" // _TIMERINTERRUPT_LOGLEVEL_ from 0 to 4 // Don't define _TIMERINTERRUPT_LOGLEVEL_ > 0. Only for special ISR debugging only. Can hang the system. // Don't define TIMER_INTERRUPT_DEBUG > 2. Only for special ISR debugging only. Can hang the system. #defineTIMER_INTERRUPT_DEBUG0 #define_TIMERINTERRUPT_LOGLEVEL_3
#include"STM32TimerInterrupt.h"
// To be included only in main(), .ino with setup() to avoid `Multiple Definitions` Linker Error #include"STM32_ISR_Timer.h"
// Depending on the board, you can select STM32 Hardware Timer from TIM1-TIM22 // For example, F767ZI can select Timer from TIM1-TIM14 // If you select a Timer not correctly, you'll get a message from ci[ompiler // 'TIMxx' was not declared in this scope; did you mean 'TIMyy'?
// Init STM32 timer TIM1 STM32Timer ITimer(TIM1);
// Init STM32_ISR_Timer // Each STM32_ISR_Timer can service 16 different ISR-based timers STM32_ISR_Timer ISR_Timer;
// In NRF52, avoid doing something fancy in ISR, for example Serial.print() // The pure simple Serial.prints here are just for demonstration and testing. Must be eliminate in working environment // Or you can get this run-time error / crash
// Here is software Timer, you can do somewhat fancy stuffs without many issues. // But always avoid // 1. Long delay() it just doing nothing and pain-without-gain wasting CPU power.Plan and design your code / strategy ahead // 2. Very long "do", "while", "for" loops without predetermined exit time. voidsimpleTimerDoingSomething2s() { staticunsignedlong previousMillis = startMillis;
for (uint16_t i = 0; i < NUMBER_ISR_TIMERS; i++) { #if USE_COMPLEX_STRUCT Serial.print(F("Timer : ")); Serial.print(i); Serial.print(F(", programmed : ")); Serial.print(curISRTimerData[i].TimerInterval); Serial.print(F(", actual : ")); Serial.println(curISRTimerData[i].deltaMillis); #else Serial.print(F("Timer : ")); Serial.print(i); Serial.print(F(", programmed : ")); Serial.print(TimerInterval[i]); Serial.print(F(", actual : ")); Serial.println(deltaMillis[i]); #endif }
previousMillis = currMillis; }
voidsetup() { pinMode(LED_BUILTIN, OUTPUT);
Serial.begin(115200); while (!Serial);
delay(100);
Serial.print(F("\nStarting ISR_16_Timers_Array_Complex on ")); Serial.println(BOARD_NAME); Serial.println(STM32_TIMER_INTERRUPT_VERSION); Serial.print(F("CPU Frequency = ")); Serial.print(F_CPU / 1000000); Serial.println(F(" MHz"));
// Interval in microsecs if (ITimer.attachInterruptInterval(HW_TIMER_INTERVAL_US, TimerHandler)) { startMillis = millis(); Serial.print(F("Starting ITimer OK, millis() = ")); Serial.println(startMillis); } else Serial.println(F("Can't set ITimer correctly. Select another freq. or interval"));
// Just to demonstrate, don't use too many ISR Timers if not absolutely necessary // You can use up to 16 timer for each STM32_ISR_Timer for (uint16_t i = 0; i < NUMBER_ISR_TIMERS; i++) { #if USE_COMPLEX_STRUCT curISRTimerData[i].previousMillis = startMillis; ISR_Timer.setInterval(curISRTimerData[i].TimerInterval, curISRTimerData[i].irqCallbackFunc); #else previousMillis[i] = startMillis; ISR_Timer.setInterval(TimerInterval[i], irqCallbackFunc[i]); #endif }
// You need this timer for non-critical tasks. Avoid abusing ISR if not absolutely necessary. simpleTimer.setInterval(SIMPLE_TIMER_MS, simpleTimerDoingSomething2s); }
#defineBLOCKING_TIME_MS10000L
voidloop() { // This unadvised blocking task is used to demonstrate the blocking effects onto the execution and accuracy to Software timer // You see the time elapse of ISR_Timer still accurate, whereas very unaccurate for Software Timer // The time elapse for 2000ms software timer now becomes 3000ms (BLOCKING_TIME_MS) // While that of ISR_Timer is still prefect. delay(BLOCKING_TIME_MS);
// You need this Software timer for non-critical tasks. Avoid abusing ISR if not absolutely necessary // You don't need to and never call ISR_Timer.run() here in the loop(). It's already handled by ISR timer. simpleTimer.run(); }
Debug Terminal Output Samples
1. ISR_Timer_Complex on STM32F7 Nucleo-144 NUCLEO_F767ZI using Built-in LAN8742A
The following is the sample terminal output when running example ISR_Timer_Complex on STM32F7 Nucleo-144 NUCLEO_F767ZI using Built-in LAN8742A Ethernet and STM32Ethernet Library to demonstrate the accuracy of ISR Hardware Timer, especially when system is very busy. The ISR timer is programmed for 2s, is activated exactly after 2.000s !!!
While software timer, programmed for 2s, is activated after 9.782s !!!. Then in loop(), it's also activated every 3s.
Starting ISR_Timer_Complex on NUCLEO_F767ZI STM32_TimerInterrupt v1.3.0 CPU Frequency = 216 MHz [TISR] Timer Input Freq (Hz) = 216000000 , Timer Clock Frequency = 1000000.00 [TISR] Timer Frequency = 10000.00 , _count = 100 Starting ITimer OK, millis() = 6 [9] MAC:FE-E1-88-EC-DD-95 2s: Delta ms = 2000 2s: Delta ms = 2000 [6626] IP:192.168.2.116 [6626] ___ __ __ / _ )/ /_ _____ / /__ / _ / / // / _ \/ '_/ /____/_/\_, /_//_/_/\_\ /___/ v0.6.1 on STM32 NUCLEO_F767ZI
[6636] BlynkArduinoClient.connect: Connecting to account.duckdns.org:8080 [6721] Ready (ping: 6ms). IP = 192.168.2.116 2s: Delta ms = 2000 blynkDoingSomething2s: Delta programmed ms = 2000, actual = 9782 2s: Delta ms = 2000 5s: Delta ms = 5000 2s: Delta ms = 2000 blynkDoingSomething2s: Delta programmed ms = 2000, actual = 3000 2s: Delta ms = 2000 5s: Delta ms = 5000 blynkDoingSomething2s: Delta programmed ms = 2000, actual = 3000 2s: Delta ms = 2000 2s: Delta ms = 2000 blynkDoingSomething2s: Delta programmed ms = 2000, actual = 3000 2s: Delta ms = 2000 5s: Delta ms = 5000 blynkDoingSomething2s: Delta programmed ms = 2000, actual = 3000 2s: Delta ms = 2000 11s: Delta ms = 11000 2s: Delta ms = 2000 blynkDoingSomething2s: Delta programmed ms = 2000, actual = 3000 5s: Delta ms = 5000 2s: Delta ms = 2000 blynkDoingSomething2s: Delta programmed ms = 2000, actual = 3000 2s: Delta ms = 2000 2s: Delta ms = 2000 5s: Delta ms = 5000 blynkDoingSomething2s: Delta programmed ms = 2000, actual = 3000 2s: Delta ms = 2000 11s: Delta ms = 11000 blynkDoingSomething2s: Delta programmed ms = 2000, actual = 3000 2s: Delta ms = 2000 5s: Delta ms = 5000 2s: Delta ms = 2000
2. TimerInterruptTest on STM32F7 Nucleo-144 NUCLEO_F767ZI
The following is the sample terminal output when running example TimerInterruptTest on STM32F7 Nucleo-144 NUCLEO_F767ZI to demonstrate how to start/stop Hardware Timers.
3. Argument_None on STM32F7 Nucleo-144 NUCLEO_F767ZI
The following is the sample terminal output when running example Argument_None on STM32G7 Nucleo-144 NUCLEO_F767ZI to demonstrate how to start/stop Multiple Hardware Timers.
4. Change_Interval on STM32F7 Nucleo-144 NUCLEO_F767ZI
The following is the sample terminal output when running example Change_Interval on STM32F7 Nucleo-144 NUCLEO_F767ZI to demonstrate how to change Timer Interval on-the-fly
5. ISR_16_Timers_Array_Complex on STM32F7 Nucleo-144 NUCLEO_F767ZI
The following is the sample terminal output when running new example ISR_16_Timers_Array_Complex on STM32F7 Nucleo-144 NUCLEO_F767ZI to demonstrate the accuracy of ISR Hardware Timer, especially when system is very busy or blocked. The 16 independent ISR timers are programmed to be activated repetitively after certain intervals, is activated exactly after that programmed interval !!!
While software timer, programmed for 2s, is activated after 10.003s in loop()!!!.
In this example, 16 independent ISR Timers are used, yet utilized just one Hardware Timer. The Timer Intervals and Function Pointers are stored in arrays to facilitate the code modification.
Starting ISR_16_Timers_Array_Complex on NUCLEO_F767ZI STM32_TimerInterrupt v1.3.0 CPU Frequency = 216 MHz [TISR] Timer Input Freq (Hz) = 216000000 , Timer Clock Frequency = 1000000.00 [TISR] Timer Frequency = 100.00 , _count = 10000 Starting ITimer OK, millis() = 12 SimpleTimer : 2s, ms = 10015, Dms : 10003 Timer : 0, programmed : 5000, actual : 5010 Timer : 1, programmed : 10000, actual : 0 Timer : 2, programmed : 15000, actual : 0 Timer : 3, programmed : 20000, actual : 0 Timer : 4, programmed : 25000, actual : 0 Timer : 5, programmed : 30000, actual : 0 Timer : 6, programmed : 35000, actual : 0 Timer : 7, programmed : 40000, actual : 0 Timer : 8, programmed : 45000, actual : 0 Timer : 9, programmed : 50000, actual : 0 Timer : 10, programmed : 55000, actual : 0 Timer : 11, programmed : 60000, actual : 0 Timer : 12, programmed : 65000, actual : 0 Timer : 13, programmed : 70000, actual : 0 Timer : 14, programmed : 75000, actual : 0 Timer : 15, programmed : 80000, actual : 0 SimpleTimer : 2s, ms = 20073, Dms : 10058 Timer : 0, programmed : 5000, actual : 5000 Timer : 1, programmed : 10000, actual : 10000 Timer : 2, programmed : 15000, actual : 15010 Timer : 3, programmed : 20000, actual : 20010 Timer : 4, programmed : 25000, actual : 0 Timer : 5, programmed : 30000, actual : 0 Timer : 6, programmed : 35000, actual : 0 Timer : 7, programmed : 40000, actual : 0 Timer : 8, programmed : 45000, actual : 0 Timer : 9, programmed : 50000, actual : 0 Timer : 10, programmed : 55000, actual : 0 Timer : 11, programmed : 60000, actual : 0 Timer : 12, programmed : 65000, actual : 0 Timer : 13, programmed : 70000, actual : 0 Timer : 14, programmed : 75000, actual : 0 Timer : 15, programmed : 80000, actual : 0 SimpleTimer : 2s, ms = 30132, Dms : 10059 Timer : 0, programmed : 5000, actual : 5000 Timer : 1, programmed : 10000, actual : 10000 Timer : 2, programmed : 15000, actual : 15000 Timer : 3, programmed : 20000, actual : 20010 Timer : 4, programmed : 25000, actual : 25010 Timer : 5, programmed : 30000, actual : 30010 Timer : 6, programmed : 35000, actual : 0 Timer : 7, programmed : 40000, actual : 0 Timer : 8, programmed : 45000, actual : 0 Timer : 9, programmed : 50000, actual : 0 Timer : 10, programmed : 55000, actual : 0 Timer : 11, programmed : 60000, actual : 0 Timer : 12, programmed : 65000, actual : 0 Timer : 13, programmed : 70000, actual : 0 Timer : 14, programmed : 75000, actual : 0 Timer : 15, programmed : 80000, actual : 0 SimpleTimer : 2s, ms = 40192, Dms : 10060 Timer : 0, programmed : 5000, actual : 5000 Timer : 1, programmed : 10000, actual : 10000 Timer : 2, programmed : 15000, actual : 15000 Timer : 3, programmed : 20000, actual : 20000 Timer : 4, programmed : 25000, actual : 25010 Timer : 5, programmed : 30000, actual : 30010 Timer : 6, programmed : 35000, actual : 35010 Timer : 7, programmed : 40000, actual : 40010 Timer : 8, programmed : 45000, actual : 0 Timer : 9, programmed : 50000, actual : 0 Timer : 10, programmed : 55000, actual : 0 Timer : 11, programmed : 60000, actual : 0 Timer : 12, programmed : 65000, actual : 0 Timer : 13, programmed : 70000, actual : 0 Timer : 14, programmed : 75000, actual : 0 Timer : 15, programmed : 80000, actual : 0 SimpleTimer : 2s, ms = 50252, Dms : 10060 Timer : 0, programmed : 5000, actual : 5000 Timer : 1, programmed : 10000, actual : 10000 Timer : 2, programmed : 15000, actual : 15000 Timer : 3, programmed : 20000, actual : 20000 Timer : 4, programmed : 25000, actual : 25000 Timer : 5, programmed : 30000, actual : 30010 Timer : 6, programmed : 35000, actual : 35010 Timer : 7, programmed : 40000, actual : 40010 Timer : 8, programmed : 45000, actual : 45010 Timer : 9, programmed : 50000, actual : 50010 Timer : 10, programmed : 55000, actual : 0 Timer : 11, programmed : 60000, actual : 0 Timer : 12, programmed : 65000, actual : 0 Timer : 13, programmed : 70000, actual : 0 Timer : 14, programmed : 75000, actual : 0 Timer : 15, programmed : 80000, actual : 0 SimpleTimer : 2s, ms = 60313, Dms : 10061 Timer : 0, programmed : 5000, actual : 5000 Timer : 1, programmed : 10000, actual : 10000 Timer : 2, programmed : 15000, actual : 15000 Timer : 3, programmed : 20000, actual : 20000 Timer : 4, programmed : 25000, actual : 25000 Timer : 5, programmed : 30000, actual : 30000 Timer : 6, programmed : 35000, actual : 35010 Timer : 7, programmed : 40000, actual : 40010 Timer : 8, programmed : 45000, actual : 45010 Timer : 9, programmed : 50000, actual : 50010 Timer : 10, programmed : 55000, actual : 55010 Timer : 11, programmed : 60000, actual : 60010 Timer : 12, programmed : 65000, actual : 0 Timer : 13, programmed : 70000, actual : 0 Timer : 14, programmed : 75000, actual : 0 Timer : 15, programmed : 80000, actual : 0 SimpleTimer : 2s, ms = 70375, Dms : 10062 Timer : 0, programmed : 5000, actual : 5000 Timer : 1, programmed : 10000, actual : 10000 Timer : 2, programmed : 15000, actual : 15000 Timer : 3, programmed : 20000, actual : 20000 Timer : 4, programmed : 25000, actual : 25000 Timer : 5, programmed : 30000, actual : 30000 Timer : 6, programmed : 35000, actual : 35000 Timer : 7, programmed : 40000, actual : 40010 Timer : 8, programmed : 45000, actual : 45010 Timer : 9, programmed : 50000, actual : 50010 Timer : 10, programmed : 55000, actual : 55010 Timer : 11, programmed : 60000, actual : 60010 Timer : 12, programmed : 65000, actual : 65010 Timer : 13, programmed : 70000, actual : 70010 Timer : 14, programmed : 75000, actual : 0 Timer : 15, programmed : 80000, actual : 0 SimpleTimer : 2s, ms = 80437, Dms : 10062 Timer : 0, programmed : 5000, actual : 4999 Timer : 1, programmed : 10000, actual : 9999 Timer : 2, programmed : 15000, actual : 15000 Timer : 3, programmed : 20000, actual : 19999 Timer : 4, programmed : 25000, actual : 25000 Timer : 5, programmed : 30000, actual : 30000 Timer : 6, programmed : 35000, actual : 35000 Timer : 7, programmed : 40000, actual : 39999 Timer : 8, programmed : 45000, actual : 45010 Timer : 9, programmed : 50000, actual : 50010 Timer : 10, programmed : 55000, actual : 55010 Timer : 11, programmed : 60000, actual : 60010 Timer : 12, programmed : 65000, actual : 65010 Timer : 13, programmed : 70000, actual : 70010 Timer : 14, programmed : 75000, actual : 75010 Timer : 15, programmed : 80000, actual : 80009 SimpleTimer : 2s, ms = 90500, Dms : 10063 Timer : 0, programmed : 5000, actual : 5000 Timer : 1, programmed : 10000, actual : 10000 Timer : 2, programmed : 15000, actual : 14999 Timer : 3, programmed : 20000, actual : 19999 Timer : 4, programmed : 25000, actual : 25000 Timer : 5, programmed : 30000, actual : 29999 Timer : 6, programmed : 35000, actual : 35000 Timer : 7, programmed : 40000, actual : 39999 Timer : 8, programmed : 45000, actual : 44999 Timer : 9, programmed : 50000, actual : 50010 Timer : 10, programmed : 55000, actual : 55010 Timer : 11, programmed : 60000, actual : 60010 Timer : 12, programmed : 65000, actual : 65010 Timer : 13, programmed : 70000, actual : 70010 Timer : 14, programmed : 75000, actual : 75010 Timer : 15, programmed : 80000, actual : 80009
6. ISR_16_Timers_Array_Complex on STM32F1 BLUEPILL_F103C8
The following is the sample terminal output when running new example ISR_16_Timers_Array_Complex on STM32F1 BLUEPILL_F103C8 to demonstrate the accuracy of ISR Hardware Timer, especially when system is very busy or blocked. The 16 independent ISR timers are programmed to be activated repetitively after certain intervals, is activated exactly after that programmed interval !!!
While software timer, programmed for 2s, is activated after 10.000s in loop()!!!.
In this example, 16 independent ISR Timers are used, yet utilized just one Hardware Timer. The Timer Intervals and Function Pointers are stored in arrays to facilitate the code modification.
Starting ISR_16_Timers_Array_Complex on BLUEPILL_F103C8 STM32_TimerInterrupt v1.3.0 CPU Frequency = 72 MHz Starting ITimer OK, millis() = 8880 SimpleTimer : 2, ms : 18880, Dms : 10000 Timer : 0, programmed : 5000, actual : 5001 Timer : 1, programmed : 10000, actual : 0 Timer : 2, programmed : 15000, actual : 0 Timer : 3, programmed : 20000, actual : 0 Timer : 4, programmed : 25000, actual : 0 Timer : 5, programmed : 30000, actual : 0 Timer : 6, programmed : 35000, actual : 0 Timer : 7, programmed : 40000, actual : 0 Timer : 8, programmed : 45000, actual : 0 Timer : 9, programmed : 50000, actual : 0 Timer : 10, programmed : 55000, actual : 0 Timer : 11, programmed : 60000, actual : 0 Timer : 12, programmed : 65000, actual : 0 Timer : 13, programmed : 70000, actual : 0 Timer : 14, programmed : 75000, actual : 0 Timer : 15, programmed : 80000, actual : 0 SimpleTimer : 2, ms : 28881, Dms : 10001 Timer : 0, programmed : 5000, actual : 5000 Timer : 1, programmed : 10000, actual : 10000 Timer : 2, programmed : 15000, actual : 15000 Timer : 3, programmed : 20000, actual : 20000 Timer : 4, programmed : 25000, actual : 0 Timer : 5, programmed : 30000, actual : 0 Timer : 6, programmed : 35000, actual : 0 Timer : 7, programmed : 40000, actual : 0 Timer : 8, programmed : 45000, actual : 0 Timer : 9, programmed : 50000, actual : 0 Timer : 10, programmed : 55000, actual : 0 Timer : 11, programmed : 60000, actual : 0 Timer : 12, programmed : 65000, actual : 0 Timer : 13, programmed : 70000, actual : 0 Timer : 14, programmed : 75000, actual : 0 Timer : 15, programmed : 80000, actual : 0 SimpleTimer : 2, ms : 38882, Dms : 10001 Timer : 0, programmed : 5000, actual : 5000 Timer : 1, programmed : 10000, actual : 10000 Timer : 2, programmed : 15000, actual : 15000 Timer : 3, programmed : 20000, actual : 20000 Timer : 4, programmed : 25000, actual : 25000 Timer : 5, programmed : 30000, actual : 30000 Timer : 6, programmed : 35000, actual : 0 Timer : 7, programmed : 40000, actual : 0 Timer : 8, programmed : 45000, actual : 0 Timer : 9, programmed : 50000, actual : 0 Timer : 10, programmed : 55000, actual : 0 Timer : 11, programmed : 60000, actual : 0 Timer : 12, programmed : 65000, actual : 0 Timer : 13, programmed : 70000, actual : 0 Timer : 14, programmed : 75000, actual : 0 Timer : 15, programmed : 80000, actual : 0 SimpleTimer : 2, ms : 48883, Dms : 10001 Timer : 0, programmed : 5000, actual : 5000 Timer : 1, programmed : 10000, actual : 10000 Timer : 2, programmed : 15000, actual : 15000 Timer : 3, programmed : 20000, actual : 20000 Timer : 4, programmed : 25000, actual : 25000 Timer : 5, programmed : 30000, actual : 30000 Timer : 6, programmed : 35000, actual : 35000 Timer : 7, programmed : 40000, actual : 40000 Timer : 8, programmed : 45000, actual : 0 Timer : 9, programmed : 50000, actual : 0 Timer : 10, programmed : 55000, actual : 0 Timer : 11, programmed : 60000, actual : 0 Timer : 12, programmed : 65000, actual : 0 Timer : 13, programmed : 70000, actual : 0 Timer : 14, programmed : 75000, actual : 0 Timer : 15, programmed : 80000, actual : 0 SimpleTimer : 2, ms : 58884, Dms : 10001 Timer : 0, programmed : 5000, actual : 5000 Timer : 1, programmed : 10000, actual : 10000 Timer : 2, programmed : 15000, actual : 15000 Timer : 3, programmed : 20000, actual : 20000 Timer : 4, programmed : 25000, actual : 25000 Timer : 5, programmed : 30000, actual : 30000 Timer : 6, programmed : 35000, actual : 35000 Timer : 7, programmed : 40000, actual : 40000 Timer : 8, programmed : 45000, actual : 45000 Timer : 9, programmed : 50000, actual : 50000 Timer : 10, programmed : 55000, actual : 0 Timer : 11, programmed : 60000, actual : 0 Timer : 12, programmed : 65000, actual : 0 Timer : 13, programmed : 70000, actual : 0 Timer : 14, programmed : 75000, actual : 0 Timer : 15, programmed : 80000, actual : 0 SimpleTimer : 2, ms : 68885, Dms : 10001 Timer : 0, programmed : 5000, actual : 5000 Timer : 1, programmed : 10000, actual : 10000 Timer : 2, programmed : 15000, actual : 15000 Timer : 3, programmed : 20000, actual : 20000 Timer : 4, programmed : 25000, actual : 25000 Timer : 5, programmed : 30000, actual : 30000 Timer : 6, programmed : 35000, actual : 35000 Timer : 7, programmed : 40000, actual : 40000 Timer : 8, programmed : 45000, actual : 45000 Timer : 9, programmed : 50000, actual : 50000 Timer : 10, programmed : 55000, actual : 55000 Timer : 11, programmed : 60000, actual : 60000 Timer : 12, programmed : 65000, actual : 0 Timer : 13, programmed : 70000, actual : 0 Timer : 14, programmed : 75000, actual : 0 Timer : 15, programmed : 80000, actual : 0 SimpleTimer : 2, ms : 78886, Dms : 10001 Timer : 0, programmed : 5000, actual : 5000 Timer : 1, programmed : 10000, actual : 10000 Timer : 2, programmed : 15000, actual : 15000 Timer : 3, programmed : 20000, actual : 20000 Timer : 4, programmed : 25000, actual : 25000 Timer : 5, programmed : 30000, actual : 30000 Timer : 6, programmed : 35000, actual : 35000 Timer : 7, programmed : 40000, actual : 40000 Timer : 8, programmed : 45000, actual : 45000 Timer : 9, programmed : 50000, actual : 50000 Timer : 10, programmed : 55000, actual : 55000 Timer : 11, programmed : 60000, actual : 60000 Timer : 12, programmed : 65000, actual : 65000 Timer : 13, programmed : 70000, actual : 70000 Timer : 14, programmed : 75000, actual : 0 Timer : 15, programmed : 80000, actual : 0 SimpleTimer : 2, ms : 88887, Dms : 10001 Timer : 0, programmed : 5000, actual : 5000 Timer : 1, programmed : 10000, actual : 10000 Timer : 2, programmed : 15000, actual : 15000 Timer : 3, programmed : 20000, actual : 20000 Timer : 4, programmed : 25000, actual : 25000 Timer : 5, programmed : 30000, actual : 30000 Timer : 6, programmed : 35000, actual : 35000 Timer : 7, programmed : 40000, actual : 40000 Timer : 8, programmed : 45000, actual : 45000 Timer : 9, programmed : 50000, actual : 50000 Timer : 10, programmed : 55000, actual : 55000 Timer : 11, programmed : 60000, actual : 60000 Timer : 12, programmed : 65000, actual : 65000 Timer : 13, programmed : 70000, actual : 70000 Timer : 14, programmed : 75000, actual : 75000 Timer : 15, programmed : 80000, actual : 80000
7. ISR_16_Timers_Array_Complex on STM32H7 NUCLEO_H743ZI2
The following is the sample terminal output when running new example ISR_16_Timers_Array_Complex on STM32H7 NUCLEO_H743ZI2 to demonstrate the accuracy of ISR Hardware Timer, especially when system is very busy or blocked. The 16 independent ISR timers are programmed to be activated repetitively after certain intervals, is activated exactly after that programmed interval !!!
While software timer, programmed for 2s, is activated after 10.000s in loop()!!!.
In this example, 16 independent ISR Timers are used, yet utilized just one Hardware Timer. The Timer Intervals and Function Pointers are stored in arrays to facilitate the code modification.
Starting ISR_16_Timers_Array_Complex on NUCLEO_H743ZI2 STM32_TimerInterrupt v1.3.0 CPU Frequency = 480 MHz Starting ITimer OK, millis() = 109 SimpleTimer : 2, ms : 10112, Dms : 10003 Timer : 0, programmed : 5000, actual : 5010 Timer : 1, programmed : 10000, actual : 10010 Timer : 2, programmed : 15000, actual : 0 Timer : 3, programmed : 20000, actual : 0 Timer : 4, programmed : 25000, actual : 0 Timer : 5, programmed : 30000, actual : 0 Timer : 6, programmed : 35000, actual : 0 Timer : 7, programmed : 40000, actual : 0 Timer : 8, programmed : 45000, actual : 0 Timer : 9, programmed : 50000, actual : 0 Timer : 10, programmed : 55000, actual : 0 Timer : 11, programmed : 60000, actual : 0 Timer : 12, programmed : 65000, actual : 0 Timer : 13, programmed : 70000, actual : 0 Timer : 14, programmed : 75000, actual : 0 Timer : 15, programmed : 80000, actual : 0 SimpleTimer : 2, ms : 20176, Dms : 10064 Timer : 0, programmed : 5000, actual : 5000 Timer : 1, programmed : 10000, actual : 10000 Timer : 2, programmed : 15000, actual : 15010 Timer : 3, programmed : 20000, actual : 20010 Timer : 4, programmed : 25000, actual : 0 Timer : 5, programmed : 30000, actual : 0 Timer : 6, programmed : 35000, actual : 0 Timer : 7, programmed : 40000, actual : 0 Timer : 8, programmed : 45000, actual : 0 Timer : 9, programmed : 50000, actual : 0 Timer : 10, programmed : 55000, actual : 0 Timer : 11, programmed : 60000, actual : 0 Timer : 12, programmed : 65000, actual : 0 Timer : 13, programmed : 70000, actual : 0 Timer : 14, programmed : 75000, actual : 0 Timer : 15, programmed : 80000, actual : 0 SimpleTimer : 2, ms : 30241, Dms : 10065 Timer : 0, programmed : 5000, actual : 5000 Timer : 1, programmed : 10000, actual : 10000 Timer : 2, programmed : 15000, actual : 15000 Timer : 3, programmed : 20000, actual : 20010 Timer : 4, programmed : 25000, actual : 25010 Timer : 5, programmed : 30000, actual : 30010 Timer : 6, programmed : 35000, actual : 0 Timer : 7, programmed : 40000, actual : 0 Timer : 8, programmed : 45000, actual : 0 Timer : 9, programmed : 50000, actual : 0 Timer : 10, programmed : 55000, actual : 0 Timer : 11, programmed : 60000, actual : 0 Timer : 12, programmed : 65000, actual : 0 Timer : 13, programmed : 70000, actual : 0 Timer : 14, programmed : 75000, actual : 0 Timer : 15, programmed : 80000, actual : 0 SimpleTimer : 2, ms : 40306, Dms : 10065 Timer : 0, programmed : 5000, actual : 5000 Timer : 1, programmed : 10000, actual : 10000 Timer : 2, programmed : 15000, actual : 15000 Timer : 3, programmed : 20000, actual : 20000 Timer : 4, programmed : 25000, actual : 25010 Timer : 5, programmed : 30000, actual : 30010 Timer : 6, programmed : 35000, actual : 35010 Timer : 7, programmed : 40000, actual : 40010 Timer : 8, programmed : 45000, actual : 0 Timer : 9, programmed : 50000, actual : 0 Timer : 10, programmed : 55000, actual : 0 Timer : 11, programmed : 60000, actual : 0 Timer : 12, programmed : 65000, actual : 0 Timer : 13, programmed : 70000, actual : 0 Timer : 14, programmed : 75000, actual : 0 Timer : 15, programmed : 80000, actual : 0 SimpleTimer : 2, ms : 50372, Dms : 10066 Timer : 0, programmed : 5000, actual : 5000 Timer : 1, programmed : 10000, actual : 10000 Timer : 2, programmed : 15000, actual : 15000 Timer : 3, programmed : 20000, actual : 20000 Timer : 4, programmed : 25000, actual : 25000 Timer : 5, programmed : 30000, actual : 30010 Timer : 6, programmed : 35000, actual : 35010 Timer : 7, programmed : 40000, actual : 40010 Timer : 8, programmed : 45000, actual : 45010 Timer : 9, programmed : 50000, actual : 50010 Timer : 10, programmed : 55000, actual : 0 Timer : 11, programmed : 60000, actual : 0 Timer : 12, programmed : 65000, actual : 0 Timer : 13, programmed : 70000, actual : 0 Timer : 14, programmed : 75000, actual : 0 Timer : 15, programmed : 80000, actual : 0 SimpleTimer : 2, ms : 60439, Dms : 10067 Timer : 0, programmed : 5000, actual : 5000 Timer : 1, programmed : 10000, actual : 9999 Timer : 2, programmed : 15000, actual : 14999 Timer : 3, programmed : 20000, actual : 19999 Timer : 4, programmed : 25000, actual : 25000 Timer : 5, programmed : 30000, actual : 29999 Timer : 6, programmed : 35000, actual : 35010 Timer : 7, programmed : 40000, actual : 40010 Timer : 8, programmed : 45000, actual : 45010 Timer : 9, programmed : 50000, actual : 50010 Timer : 10, programmed : 55000, actual : 55009 Timer : 11, programmed : 60000, actual : 60009 Timer : 12, programmed : 65000, actual : 0 Timer : 13, programmed : 70000, actual : 0 Timer : 14, programmed : 75000, actual : 0 Timer : 15, programmed : 80000, actual : 0 SimpleTimer : 2, ms : 70506, Dms : 10067 Timer : 0, programmed : 5000, actual : 5000 Timer : 1, programmed : 10000, actual : 10000 Timer : 2, programmed : 15000, actual : 14999 Timer : 3, programmed : 20000, actual : 19999 Timer : 4, programmed : 25000, actual : 25000 Timer : 5, programmed : 30000, actual : 29999 Timer : 6, programmed : 35000, actual : 34999 Timer : 7, programmed : 40000, actual : 40010 Timer : 8, programmed : 45000, actual : 45010 Timer : 9, programmed : 50000, actual : 50010 Timer : 10, programmed : 55000, actual : 55009 Timer : 11, programmed : 60000, actual : 60009 Timer : 12, programmed : 65000, actual : 65009 Timer : 13, programmed : 70000, actual : 70009 Timer : 14, programmed : 75000, actual : 0 Timer : 15, programmed : 80000, actual : 0 SimpleTimer : 2, ms : 80574, Dms : 10068 Timer : 0, programmed : 5000, actual : 5000 Timer : 1, programmed : 10000, actual : 10000 Timer : 2, programmed : 15000, actual : 15000 Timer : 3, programmed : 20000, actual : 20000 Timer : 4, programmed : 25000, actual : 24999 Timer : 5, programmed : 30000, actual : 29999 Timer : 6, programmed : 35000, actual : 34999 Timer : 7, programmed : 40000, actual : 39999 Timer : 8, programmed : 45000, actual : 45010 Timer : 9, programmed : 50000, actual : 50010 Timer : 10, programmed : 55000, actual : 55009 Timer : 11, programmed : 60000, actual : 60009 Timer : 12, programmed : 65000, actual : 65009 Timer : 13, programmed : 70000, actual : 70009 Timer : 14, programmed : 75000, actual : 75009 Timer : 15, programmed : 80000, actual : 80009
8. ISR_16_Timers_Array_Complex on STM32L5 NUCLEO_L552ZE_Q
The following is the sample terminal output when running new example ISR_16_Timers_Array_Complex on STM32L5 NUCLEO_L552ZE_Q to demonstrate the accuracy of ISR Hardware Timer, especially when system is very busy or blocked. The 16 independent ISR timers are programmed to be activated repetitively after certain intervals, is activated exactly after that programmed interval !!!
While software timer, programmed for 2s, is activated after 10.000s in loop()!!!.
In this example, 16 independent ISR Timers are used, yet utilized just one Hardware Timer. The Timer Intervals and Function Pointers are stored in arrays to facilitate the code modification.
Starting ISR_16_Timers_Array_Complex on NUCLEO_L552ZE_Q STM32_TimerInterrupt v1.3.0 CPU Frequency = 110 MHz Starting ITimer OK, millis() = 109 SimpleTimer : 2, ms : 10112, Dms : 10003 Timer : 0, programmed : 5000, actual : 5011 Timer : 1, programmed : 10000, actual : 10011 Timer : 2, programmed : 15000, actual : 0 Timer : 3, programmed : 20000, actual : 0 Timer : 4, programmed : 25000, actual : 0 Timer : 5, programmed : 30000, actual : 0 Timer : 6, programmed : 35000, actual : 0 Timer : 7, programmed : 40000, actual : 0 Timer : 8, programmed : 45000, actual : 0 Timer : 9, programmed : 50000, actual : 0 Timer : 10, programmed : 55000, actual : 0 Timer : 11, programmed : 60000, actual : 0 Timer : 12, programmed : 65000, actual : 0 Timer : 13, programmed : 70000, actual : 0 Timer : 14, programmed : 75000, actual : 0 Timer : 15, programmed : 80000, actual : 0 SimpleTimer : 2, ms : 20177, Dms : 10065 Timer : 0, programmed : 5000, actual : 4999 Timer : 1, programmed : 10000, actual : 9999 Timer : 2, programmed : 15000, actual : 15011 Timer : 3, programmed : 20000, actual : 20010 Timer : 4, programmed : 25000, actual : 0 Timer : 5, programmed : 30000, actual : 0 Timer : 6, programmed : 35000, actual : 0 Timer : 7, programmed : 40000, actual : 0 Timer : 8, programmed : 45000, actual : 0 Timer : 9, programmed : 50000, actual : 0 Timer : 10, programmed : 55000, actual : 0 Timer : 11, programmed : 60000, actual : 0 Timer : 12, programmed : 65000, actual : 0 Timer : 13, programmed : 70000, actual : 0 Timer : 14, programmed : 75000, actual : 0 Timer : 15, programmed : 80000, actual : 0 SimpleTimer : 2, ms : 30242, Dms : 10065 Timer : 0, programmed : 5000, actual : 5000 Timer : 1, programmed : 10000, actual : 10000 Timer : 2, programmed : 15000, actual : 14999 Timer : 3, programmed : 20000, actual : 20010 Timer : 4, programmed : 25000, actual : 25010 Timer : 5, programmed : 30000, actual : 30010 Timer : 6, programmed : 35000, actual : 0 Timer : 7, programmed : 40000, actual : 0 Timer : 8, programmed : 45000, actual : 0 Timer : 9, programmed : 50000, actual : 0 Timer : 10, programmed : 55000, actual : 0 Timer : 11, programmed : 60000, actual : 0 Timer : 12, programmed : 65000, actual : 0 Timer : 13, programmed : 70000, actual : 0 Timer : 14, programmed : 75000, actual : 0 Timer : 15, programmed : 80000, actual : 0 SimpleTimer : 2, ms : 40308, Dms : 10066 Timer : 0, programmed : 5000, actual : 5000 Timer : 1, programmed : 10000, actual : 10000 Timer : 2, programmed : 15000, actual : 14999 Timer : 3, programmed : 20000, actual : 20000 Timer : 4, programmed : 25000, actual : 25010 Timer : 5, programmed : 30000, actual : 30010 Timer : 6, programmed : 35000, actual : 35010 Timer : 7, programmed : 40000, actual : 40010 Timer : 8, programmed : 45000, actual : 0 Timer : 9, programmed : 50000, actual : 0 Timer : 10, programmed : 55000, actual : 0 Timer : 11, programmed : 60000, actual : 0 Timer : 12, programmed : 65000, actual : 0 Timer : 13, programmed : 70000, actual : 0 Timer : 14, programmed : 75000, actual : 0 Timer : 15, programmed : 80000, actual : 0 SimpleTimer : 2, ms : 50375, Dms : 10067 Timer : 0, programmed : 5000, actual : 5000 Timer : 1, programmed : 10000, actual : 10000 Timer : 2, programmed : 15000, actual : 15000 Timer : 3, programmed : 20000, actual : 20000 Timer : 4, programmed : 25000, actual : 25000 Timer : 5, programmed : 30000, actual : 30010 Timer : 6, programmed : 35000, actual : 35010 Timer : 7, programmed : 40000, actual : 40010 Timer : 8, programmed : 45000, actual : 45010 Timer : 9, programmed : 50000, actual : 50010 Timer : 10, programmed : 55000, actual : 0 Timer : 11, programmed : 60000, actual : 0 Timer : 12, programmed : 65000, actual : 0 Timer : 13, programmed : 70000, actual : 0 Timer : 14, programmed : 75000, actual : 0 Timer : 15, programmed : 80000, actual : 0 SimpleTimer : 2, ms : 60443, Dms : 10068 Timer : 0, programmed : 5000, actual : 5000 Timer : 1, programmed : 10000, actual : 10000 Timer : 2, programmed : 15000, actual : 15000 Timer : 3, programmed : 20000, actual : 20000 Timer : 4, programmed : 25000, actual : 25000 Timer : 5, programmed : 30000, actual : 30000 Timer : 6, programmed : 35000, actual : 35010 Timer : 7, programmed : 40000, actual : 40010 Timer : 8, programmed : 45000, actual : 45010 Timer : 9, programmed : 50000, actual : 50010 Timer : 10, programmed : 55000, actual : 55010 Timer : 11, programmed : 60000, actual : 60010 Timer : 12, programmed : 65000, actual : 0 Timer : 13, programmed : 70000, actual : 0 Timer : 14, programmed : 75000, actual : 0 Timer : 15, programmed : 80000, actual : 0 SimpleTimer : 2, ms : 70511, Dms : 10068 Timer : 0, programmed : 5000, actual : 5000 Timer : 1, programmed : 10000, actual : 10000 Timer : 2, programmed : 15000, actual : 15000 Timer : 3, programmed : 20000, actual : 20000 Timer : 4, programmed : 25000, actual : 25000 Timer : 5, programmed : 30000, actual : 30000 Timer : 6, programmed : 35000, actual : 35000 Timer : 7, programmed : 40000, actual : 40010 Timer : 8, programmed : 45000, actual : 45010 Timer : 9, programmed : 50000, actual : 50010 Timer : 10, programmed : 55000, actual : 55010 Timer : 11, programmed : 60000, actual : 60010 Timer : 12, programmed : 65000, actual : 65010 Timer : 13, programmed : 70000, actual : 70010 Timer : 14, programmed : 75000, actual : 0 Timer : 15, programmed : 80000, actual : 0 SimpleTimer : 2, ms : 80580, Dms : 10069 Timer : 0, programmed : 5000, actual : 5000 Timer : 1, programmed : 10000, actual : 10000 Timer : 2, programmed : 15000, actual : 15000 Timer : 3, programmed : 20000, actual : 20000 Timer : 4, programmed : 25000, actual : 25000 Timer : 5, programmed : 30000, actual : 30000 Timer : 6, programmed : 35000, actual : 35000 Timer : 7, programmed : 40000, actual : 40000 Timer : 8, programmed : 45000, actual : 45010 Timer : 9, programmed : 50000, actual : 50010 Timer : 10, programmed : 55000, actual : 55010 Timer : 11, programmed : 60000, actual : 60010 Timer : 12, programmed : 65000, actual : 65010 Timer : 13, programmed : 70000, actual : 70010 Timer : 14, programmed : 75000, actual : 75010 Timer : 15, programmed : 80000, actual : 80010
Debug
Debug is enabled by default on Serial.
You can also change the debugging level (TIMERINTERRUPT_LOGLEVEL) from 0 to 4
0. Only for special ISR debugging only. Can hang the system.
#define TIMER_INTERRUPT_DEBUG 0
#define _TIMERINTERRUPT_LOGLEVEL_ 0">// These define's must be placed at the beginning before #include "STM32_TimerInterrupt.h" // _TIMERINTERRUPT_LOGLEVEL_ from 0 to 4 // Don't define _TIMERINTERRUPT_LOGLEVEL_ > 0. Only for special ISR debugging only. Can hang the system. #defineTIMER_INTERRUPT_DEBUG0 #define_TIMERINTERRUPT_LOGLEVEL_0
Troubleshooting
If you get compilation errors, more often than not, you may need to install a newer version of the core for Arduino boards.
Sometimes, the library will only work if you update the board core to the latest version because I am using newly added functions.
This library enables you to use Interrupt from Hardware Timers on an STM32F/L/H/G/WB/MP1-based board. These STM32F/L/H/G/WB/MP1 Hardware Timers, using Interrupt, still work even if other functions are blocking. Moreover, they are much more precise (certainly depending on clock frequency accuracy) than other software timers using millis() or micr...