New Portenta_H7_TimerInterrupt Library

Portenta_H7_TimerInterrupt library GitHub release
How To Install Using Arduino Library Manager


Features

This library enables you to use Interrupt from Hardware Timers on an STM32H7-based Portenta_H7 board.

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 miliseconds) 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_16_Timers_Array_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 or 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


Currently Supported Boards

This Portenta_H7_TimerInterrupt library currently supports the following boards:

  1. Portenta_H7 boards, using ArduinoCore-mbed mbed_portenta core


Changelog

Initial Releases v1.2.1

  1. Initial coding to support Portenta_H7 boards such as Portenta_H7 Rev2 ABX00042, etc., using ArduinoCore-mbed mbed_portenta core
  2. Permit up to 16 super-long-time, super-accurate ISR-based timers to avoid being blocked
  3. Using cpp code besides Impl.h code to use if Multiple-Definition linker error.
  4. Bump version to v1.2.1 to sync with STM32_TimerInterrupt library

Examples

  1. Argument_None
  2. Change_Interval
  3. ISR_16_Timers_Array
  4. ISR_16_Timers_Array_Complex
  5. SwitchDebounce
  6. TimerInterruptLEDDemo
  7. TimerInterruptTest

Debug Terminal Output Samples

1. ISR_16_Timers_Array_Complex on PORTENTA_H7_M7

This is the terminal output when running ISR_16_Timers_Array_Complex on Portenta_H7 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-based SimpleTimer, programmed for 2s, is activated after 10.000s !!!.

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 PORTENTA_H7_M7
Portenta_H7_TimerInterrupt v1.2.1
[TISR] Portenta_H7_TimerInterrupt: Timer Input Freq (Hz) = 200000000
[TISR] Frequency = 1000000.00 , _count = 10000
Starting ITimer OK, millis() = 1111
SimpleTimer : 2, ms : 11111, Dms : 10000
Timer : 0, programmed : 5000, actual : 5004
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 : 21114, Dms : 10003
Timer : 0, programmed : 5000, actual : 4994
Timer : 1, programmed : 10000, actual : 10008
Timer : 2, programmed : 15000, actual : 15002
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 : 31117, Dms : 10003
Timer : 0, programmed : 5000, actual : 5005
Timer : 1, programmed : 10000, actual : 9999
Timer : 2, programmed : 15000, actual : 15003
Timer : 3, programmed : 20000, actual : 20006
Timer : 4, programmed : 25000, actual : 25000
Timer : 5, programmed : 30000, actual : 30005
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 : 41120, Dms : 10003
Timer : 0, programmed : 5000, actual : 4994
Timer : 1, programmed : 10000, actual : 9998
Timer : 2, programmed : 15000, actual : 15003
Timer : 3, programmed : 20000, actual : 19997
Timer : 4, programmed : 25000, actual : 25000
Timer : 5, programmed : 30000, actual : 30005
Timer : 6, programmed : 35000, actual : 35009
Timer : 7, programmed : 40000, actual : 40003
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 : 51123, Dms : 10003
Timer : 0, programmed : 5000, actual : 4995
Timer : 1, programmed : 10000, actual : 9999
Timer : 2, programmed : 15000, actual : 15002
Timer : 3, programmed : 20000, actual : 19997
Timer : 4, programmed : 25000, actual : 25002
Timer : 5, programmed : 30000, actual : 30005
Timer : 6, programmed : 35000, actual : 35009
Timer : 7, programmed : 40000, actual : 40003
Timer : 8, programmed : 45000, actual : 45007
Timer : 9, programmed : 50000, actual : 50002
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 : 61126, Dms : 10003
Timer : 0, programmed : 5000, actual : 4994
Timer : 1, programmed : 10000, actual : 9998
Timer : 2, programmed : 15000, actual : 14993
Timer : 3, programmed : 20000, actual : 19997
Timer : 4, programmed : 25000, actual : 25002
Timer : 5, programmed : 30000, actual : 29995
Timer : 6, programmed : 35000, actual : 35009
Timer : 7, programmed : 40000, actual : 40003
Timer : 8, programmed : 45000, actual : 45007
Timer : 9, programmed : 50000, actual : 50002
Timer : 10, programmed : 55000, actual : 55006
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 : 71129, Dms : 10003
Timer : 0, programmed : 5000, actual : 5005
Timer : 1, programmed : 10000, actual : 10009
Timer : 2, programmed : 15000, actual : 14993
Timer : 3, programmed : 20000, actual : 19997
Timer : 4, programmed : 25000, actual : 25002
Timer : 5, programmed : 30000, actual : 29995
Timer : 6, programmed : 35000, actual : 35000
Timer : 7, programmed : 40000, actual : 40003
Timer : 8, programmed : 45000, actual : 45007
Timer : 9, programmed : 50000, actual : 50002
Timer : 10, programmed : 55000, actual : 55006
Timer : 11, programmed : 60000, actual : 60000
Timer : 12, programmed : 65000, actual : 65004
Timer : 13, programmed : 70000, actual : 70009
Timer : 14, programmed : 75000, actual : 0
Timer : 15, programmed : 80000, actual : 0
SimpleTimer : 2, ms : 81132, Dms : 10003
Timer : 0, programmed : 5000, actual : 5005
Timer : 1, programmed : 10000, actual : 9999
Timer : 2, programmed : 15000, actual : 15003
Timer : 3, programmed : 20000, actual : 20008
Timer : 4, programmed : 25000, actual : 25001
Timer : 5, programmed : 30000, actual : 29995
Timer : 6, programmed : 35000, actual : 35000
Timer : 7, programmed : 40000, actual : 40005
Timer : 8, programmed : 45000, actual : 45007
Timer : 9, programmed : 50000, actual : 50002
Timer : 10, programmed : 55000, actual : 55006
Timer : 11, programmed : 60000, actual : 60000
Timer : 12, programmed : 65000, actual : 65004
Timer : 13, programmed : 70000, actual : 70009
Timer : 14, programmed : 75000, actual : 75003
Timer : 15, programmed : 80000, actual : 80008
1 Like

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.