Skip to content
This repository was archived by the owner on Jan 29, 2023. It is now read-only.

Commit 31ef891

Browse files
authored
v1.4.0 to fix HF bug
### Release v1.4.0 1. Fix TCB Clock bug in high frequencies. Check [Interrupt interval 2X requested interval #1](#1) 2. Add example to demo High Frequency 3. Delete Blynk-related examples 4. Add changelog.md
1 parent 45561ff commit 31ef891

31 files changed

+449
-344
lines changed

CONTRIBUTING.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ If you don't find anything, please [open a new issue](https://github.com/khoih-p
1414

1515
Please ensure to specify the following:
1616

17-
* Arduino IDE version (e.g. 1.8.13) or Platform.io version
17+
* Arduino IDE version (e.g. 1.8.16) or Platform.io version
1818
* `Arduino megaAVR` Core Version (e.g. Arduino megaAVR core v1.8.7)
1919
* Contextual information (e.g. what you were trying to achieve)
2020
* Simplest possible steps to reproduce
@@ -26,10 +26,10 @@ Please ensure to specify the following:
2626
### Example
2727

2828
```
29-
Arduino IDE version: 1.8.13
29+
Arduino IDE version: 1.8.16
3030
Arduino megaAVR Core Version 1.8.7
3131
OS: Ubuntu 20.04 LTS
32-
Linux xy-Inspiron-3593 5.4.0-71-generic #79-Ubuntu SMP Wed Mar 24 10:56:57 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux
32+
Linux xy-Inspiron-3593 5.4.0-90-generic #101-Ubuntu SMP Fri Oct 15 20:00:55 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux
3333
3434
Context:
3535
I encountered a crash while trying to use the Timer Interrupt.

README.md

Lines changed: 58 additions & 97 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,7 @@
1313
* [Why using ISR-based Hardware Timer Interrupt is better](#why-using-isr-based-hardware-timer-interrupt-is-better)
1414
* [Important Notes about ISR](#important-notes-about-isr)
1515
* [Currently supported Boards](#currently-supported-boards)
16-
* [Changelog](#changelog)
17-
* [Release v1.3.0](#release-v130)
18-
* [Release v1.2.0](#release-v120)
19-
* [Release v1.1.0](#release-v110)
20-
* [Initial Release v1.0.0](#initial-release-v100)
16+
* [Changelog](changelog.md)
2117
* [Prerequisites](#prerequisites)
2218
* [Installation](#installation)
2319
* [Use Arduino Library Manager](#use-arduino-library-manager)
@@ -40,19 +36,16 @@
4036
* [ 1. Argument_Complex](examples/Argument_Complex)
4137
* [ 2. Argument_None](examples/Argument_None)
4238
* [ 3. Argument_Simple](examples/Argument_Simple)
43-
* [ 4. **Change_Interval**](examples/Change_Interval).
44-
* [ 5. **FakeAnalogWrite**](examples/FakeAnalogWrite).
39+
* [ 4. Change_Interval](examples/Change_Interval)
40+
* [ 5. FakeAnalogWrite](examples/FakeAnalogWrite)
4541
* [ 6. **ISR_16_Timers_Array_Complex**](examples/ISR_16_Timers_Array_Complex).
4642
* [ 7. ISR_RPM_Measure](examples/ISR_RPM_Measure)
47-
* [ 8. ISR_Switch](examples/ISR_Switch)
48-
* [ 9. ISR_Timer_Complex](examples/ISR_Timer_Complex)
49-
* [ 10. **ISR_Timers_Array_Simple**](examples/ISR_Timers_Array_Simple).
50-
* [ 11. ISR_Timer_Switch](examples/ISR_Timer_Switch)
51-
* [ 12. ISR_Timer_Switches](examples/ISR_Timer_Switches)
52-
* [ 13. RPM_Measure](examples/RPM_Measure)
53-
* [ 14. SwitchDebounce](examples/SwitchDebounce)
54-
* [ 15. TimerDuration](examples/TimerDuration)
55-
* [ 16. TimerInterruptTest](examples/TimerInterruptTest)
43+
* [ 8. **Change_Interval_HF**](examples/Change_Interval_HF)
44+
* [ 9. **ISR_Timers_Array_Simple**](examples/ISR_Timers_Array_Simple).
45+
* [ 10. RPM_Measure](examples/RPM_Measure)
46+
* [ 11. SwitchDebounce](examples/SwitchDebounce)
47+
* [ 12. TimerDuration](examples/TimerDuration)
48+
* [ 13. TimerInterruptTest](examples/TimerInterruptTest)
5649
* [Example ISR_16_Timers_Array_Complex](#example-isr_16_timers_array_complex)
5750
* [Debug Terminal Output Samples](#debug-terminal-output-samples)
5851
* [1. ISR_16_Timers_Array_Complex on Arduino megaAVR Nano Every](#1-isr_16_timers_array_complex-on-arduino-megaavr-nano-every)
@@ -63,7 +56,6 @@
6356
* [3.3 TCB Clock Frequency 250KHz for lower accuracy but longer time](#33-tcb-clock-frequency-250khz-for-lower-accuracy-but-longer-time)
6457
* [Debug](#debug)
6558
* [Troubleshooting](#troubleshooting)
66-
* [Releases](#releases)
6759
* [Issues](#issues)
6860
* [TO DO](#to-do)
6961
* [DONE](#done)
@@ -125,31 +117,6 @@ The catch is your function is now part of an ISR (Interrupt Service Routine), an
125117
- **Arduino UNO WiFi Rev2, AVR_NANO_EVERY, etc.**
126118
- ATmega4809-based boards.
127119

128-
---
129-
---
130-
131-
## Changelog
132-
133-
### Release v1.3.0
134-
135-
1. Fix TCB Clock bug. Don't use v1.2.0
136-
137-
138-
### Release v1.2.0
139-
140-
1. Selectable **TCB Clock 16MHz, 8MHz or 250KHz** depending on necessary accuracy
141-
2. Add BOARD_NAME definition
142-
143-
### Release v1.1.0
144-
145-
1. Fix bug. Don't use v1.0.0
146-
147-
### Initial Release v1.0.0
148-
149-
1. Intial release to support to ATmega4809-based boards, such as **Arduino UNO WiFi Rev2, AVR_NANO_EVERY, etc.**
150-
2. New examples to support Blynk using [**WiFiNINA_Generic**](https://github.com/khoih-prog/WiFiNINA_Generic) and [**Blynk_WiFiNINA_WM**](https://github.com/khoih-prog/Blynk_WiFiNINA_WM) libraries.
151-
152-
153120
---
154121
---
155122

@@ -429,19 +396,16 @@ void setup()
429396
1. [Argument_Complex](examples/Argument_Complex)
430397
2. [Argument_None](examples/Argument_None)
431398
3. [Argument_Simple](examples/Argument_Simple)
432-
4. [**Change_Interval**](examples/Change_Interval).
433-
5. [**FakeAnalogWrite**](examples/FakeAnalogWrite).
399+
4. [Change_Interval](examples/Change_Interval).
400+
5. [FakeAnalogWrite](examples/FakeAnalogWrite).
434401
6. [**ISR_16_Timers_Array_Complex**](examples/ISR_16_Timers_Array_Complex).
435402
7. [ISR_RPM_Measure](examples/ISR_RPM_Measure)
436-
8. [ISR_Switch](examples/ISR_Switch)
437-
9. [ISR_Timer_Complex](examples/ISR_Timer_Complex)
438-
10. [**ISR_Timers_Array_Simple**](examples/ISR_Timers_Array_Simple).
439-
11. [ISR_Timer_Switch](examples/ISR_Timer_Switch)
440-
12. [ISR_Timer_Switches](examples/ISR_Timer_Switches)
441-
13. [RPM_Measure](examples/RPM_Measure)
442-
14. [SwitchDebounce](examples/SwitchDebounce)
443-
15. [TimerDuration](examples/TimerDuration)
444-
16. [TimerInterruptTest](examples/TimerInterruptTest)
403+
8. [**Change_Interval_HF**](examples/Change_Interval_HF)
404+
9. [**ISR_Timers_Array_Simple**](examples/ISR_Timers_Array_Simple).
405+
10. [RPM_Measure](examples/RPM_Measure)
406+
11. [SwitchDebounce](examples/SwitchDebounce)
407+
12. [TimerDuration](examples/TimerDuration)
408+
13. [TimerInterruptTest](examples/TimerInterruptTest)
445409

446410
---
447411

@@ -799,7 +763,7 @@ While software timer, **programmed for 2s, is activated after more than 10.000s
799763
```
800764

801765
Starting ISR_16_Timers_Array_Complex on megaAVR Nano Every
802-
megaAVR_TimerInterrupt v1.3.0
766+
megaAVR_TimerInterrupt v1.4.0
803767
CPU Frequency = 16 MHz
804768
TCB Clock Frequency = 250KHz for lower accuracy but longer time
805769
Starting ITimer1 OK, millis() = 6
@@ -951,7 +915,7 @@ The following is the sample terminal output when running example [Change_Interva
951915
952916
```
953917
Starting Change_Interval on megaAVR Nano Every
954-
megaAVR_TimerInterrupt v1.3.0
918+
megaAVR_TimerInterrupt v1.4.0
955919
CPU Frequency = 16 MHz
956920
TCB Clock Frequency = 250KHz for lower accuracy but longer time
957921
Starting ITimer1 OK, millis() = 1
@@ -980,7 +944,7 @@ Changing Interval, Timer1 = 100, Timer2 = 200
980944
981945
```
982946
Starting ISR_16_Timers_Array_Complex on megaAVR Nano Every
983-
megaAVR_TimerInterrupt v1.3.0
947+
megaAVR_TimerInterrupt v1.4.0
984948
CPU Frequency = 16 MHz
985949
TCB Clock Frequency = 16MHz for highest accuracy
986950
Starting ITimer1 OK, millis() = 6
@@ -1066,7 +1030,7 @@ Timer : 15, programmed : 80000, actual : 80000
10661030
```
10671031

10681032
Starting ISR_16_Timers_Array_Complex on megaAVR Nano Every
1069-
megaAVR_TimerInterrupt v1.3.0
1033+
megaAVR_TimerInterrupt v1.4.0
10701034
CPU Frequency = 16 MHz
10711035
TCB Clock Frequency = 8MHz for very high accuracy
10721036
Starting ITimer1 OK, millis() = 10
@@ -1134,7 +1098,7 @@ Timer : 15, programmed : 80000, actual : 80000
11341098
11351099
```
11361100
Starting ISR_16_Timers_Array_Complex on megaAVR Nano Every
1137-
megaAVR_TimerInterrupt v1.3.0
1101+
megaAVR_TimerInterrupt v1.4.0
11381102
CPU Frequency = 16 MHz
11391103
TCB Clock Frequency = 250KHz for lower accuracy but longer time
11401104
Starting ITimer1 OK, millis() = 11
@@ -1212,6 +1176,40 @@ Timer : 14, programmed : 75000, actual : 75000
12121176
Timer : 15, programmed : 80000, actual : 80004
12131177
```
12141178
1179+
---
1180+
1181+
### 4. Change_Interval_HF on Arduino megaAVR Nano Every
1182+
1183+
The following is the sample terminal output when running example [Change_Interval_HF](examples/Change_Interval_HF) on **Arduino megaAVR Nano Every** to demonstrate how to change High Frequency Timer Interval on-the-fly
1184+
1185+
```
1186+
Starting Change_Interval_HF on megaAVR Nano Every
1187+
megaAVR_TimerInterrupt v1.4.0
1188+
CPU Frequency = 16 MHz
1189+
TCB Clock Frequency = 16MHz for highest accuracy
1190+
[TISR] TCB 1
1191+
[TISR] ==================
1192+
[TISR] Init, Timer = 1
1193+
[TISR] CTRLB = 0
1194+
[TISR] CCMP = 65535
1195+
[TISR] INTCTRL = 0
1196+
[TISR] CTRLA = 1
1197+
[TISR] ==================
1198+
[TISR] Frequency = 10000.00 , CLK_TCB_FREQ = 16000000
1199+
[TISR] setFrequency: _CCMPValueRemaining = 1600
1200+
Starting ITimer1 OK, millis() = 12
1201+
Frequency, Timer1 = 10000
1202+
Time = 10001, Timer1Count = 99856
1203+
Time = 20002, Timer1Count = 199807
1204+
[TISR] Frequency = 5000.00 , CLK_TCB_FREQ = 16000000
1205+
[TISR] setFrequency: _CCMPValueRemaining = 3200
1206+
Changing Frequency, Timer1 = 5000
1207+
Time = 30003, Timer1Count = 249792
1208+
Time = 40004, Timer1Count = 299784
1209+
[TISR] Frequency = 10000.00 , CLK_TCB_FREQ = 16000000
1210+
[TISR] setFrequency: _CCMPValueRemaining = 1600
1211+
Changing Frequency, Timer1 = 10000
1212+
```
12151213
12161214
12171215
---
@@ -1241,44 +1239,6 @@ If you get compilation errors, more often than not, you may need to install a ne
12411239
Sometimes, the library will only work if you update the board core to the latest version because I am using newly added functions.
12421240

12431241

1244-
---
1245-
---
1246-
1247-
## Releases
1248-
1249-
### Release v1.3.0
1250-
1251-
1. Fix TCB Clock bug. Don't use v1.2.0
1252-
1253-
### Release v1.2.0
1254-
1255-
1. Selectable **TCB Clock 16MHz, 8MHz or 250KHz** depending on necessary accuracy
1256-
2. Add BOARD_NAME definition
1257-
1258-
### Release v1.1.0
1259-
1260-
1. Fix bug. Don't use v1.0.0
1261-
1262-
### Initial Release v1.0.0
1263-
1264-
1. Intial release to support to ATmega4809-based boards, such as **Arduino UNO WiFi Rev2, AVR_NANO_EVERY, etc.**
1265-
2. New examples to support Blynk using [**WiFiNINA_Generic**](https://github.com/khoih-prog/WiFiNINA_Generic) and [**Blynk_WiFiNINA_WM**](https://github.com/khoih-prog/Blynk_WiFiNINA_WM) libraries.
1266-
1267-
The [**ISR_Timer_Complex**](examples/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.
1268-
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.
1269-
1270-
This non-being-blocked important feature is absolutely necessary for mission-critical tasks.
1271-
1272-
You'll see blynkTimer Software is blocked while system is connecting to WiFi / Internet / Blynk, as well as by blocking task
1273-
in loop(), using delay() function as an example. The elapsed time then is very unaccurate
1274-
1275-
---
1276-
1277-
### Currently supported Boards
1278-
1279-
- **Arduino UNO WiFi Rev2, AVR_NANO_EVERY, etc.**
1280-
- ATmega4809-based boards.
1281-
12821242
---
12831243
---
12841244

@@ -1314,11 +1274,12 @@ Submit issues to: [megaAVR_TimerInterrupt issues](https://github.com/khoih-prog/
13141274
Many thanks for everyone for bug reporting, new feature suggesting, testing and contributing to the development of this library. Especially to these people who have directly or indirectly contributed to this [megaAVR_TimerInterrupt library](https://github.com/khoih-prog/megaAVR_TimerInterrupt)
13151275

13161276
1. Thanks to good work of [Miguel Wisintainer](https://github.com/tcpipchip) for initiating, inspriring, working with, developing, debugging, testing and maintaining.
1317-
1277+
2. Thanks to [Bill Wuttke](https://github.com/wcwuttke) to report the issue [Interrupt interval 2X requested interval #1](https://github.com/khoih-prog/megaAVR_TimerInterrupt/issues/1) leading to new release v1.4.0 to fix bug in using higher frequencies than 250Hz.
13181278

13191279
<table>
13201280
<tr>
13211281
<td align="center"><a href="https://github.com/tcpipchip"><img src="https://github.com/tcpipchip.png" width="100px;" alt="tcpipchip"/><br/><sub><b>⭐️ Miguel Wisintainer</b></sub></a><br/></td>
1282+
<td align="center"><a href="https://github.com/wcwuttke"><img src="https://github.com/wcwuttke.png" width="100px;" alt="wcwuttke"/><br/><sub><b>Bill Wuttke</b></sub></a><br/></td>
13221283
</tr>
13231284
</table>
13241285

changelog.md

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
## megaAVR_TimerInterrupt Library
2+
3+
[![arduino-library-badge](https://www.ardu-badge.com/badge/megaAVR_TimerInterrupt.svg?)](https://www.ardu-badge.com/megaAVR_TimerInterrupt)
4+
[![GitHub release](https://img.shields.io/github/release/khoih-prog/megaAVR_TimerInterrupt.svg)](https://github.com/khoih-prog/megaAVR_TimerInterrupt/releases)
5+
[![GitHub](https://img.shields.io/github/license/mashape/apistatus.svg)](https://github.com/khoih-prog/megaAVR_TimerInterrupt/blob/master/LICENSE)
6+
[![contributions welcome](https://img.shields.io/badge/contributions-welcome-brightgreen.svg?style=flat)](#Contributing)
7+
[![GitHub issues](https://img.shields.io/github/issues/khoih-prog/megaAVR_TimerInterrupt.svg)](http://github.com/khoih-prog/megaAVR_TimerInterrupt/issues)
8+
9+
## Table of Contents
10+
11+
* [Changelog](#changelog)
12+
* [Release v1.4.0](#release-v140)
13+
* [Release v1.3.0](#release-v130)
14+
* [Release v1.2.0](#release-v120)
15+
* [Release v1.1.0](#release-v110)
16+
* [Initial Release v1.0.0](#initial-release-v100)
17+
18+
---
19+
---
20+
21+
## Changelog
22+
23+
### Release v1.4.0
24+
25+
1. Fix TCB Clock bug in high frequencies. Check [Interrupt interval 2X requested interval #1](https://github.com/khoih-prog/megaAVR_TimerInterrupt/issues/1)
26+
2. Add example to demo High Frequency
27+
3. Delete Blynk-related examples
28+
4. Add changelog.md
29+
30+
### Release v1.3.0
31+
32+
1. Fix TCB Clock bug. Don't use v1.2.0
33+
34+
35+
### Release v1.2.0
36+
37+
1. Selectable **TCB Clock 16MHz, 8MHz or 250KHz** depending on necessary accuracy
38+
2. Add BOARD_NAME definition
39+
40+
### Release v1.1.0
41+
42+
1. Fix bug. Don't use v1.0.0
43+
44+
### Initial Release v1.0.0
45+
46+
1. Intial release to support to ATmega4809-based boards, such as **Arduino UNO WiFi Rev2, AVR_NANO_EVERY, etc.**
47+
2. New examples to support Blynk using [**WiFiNINA_Generic**](https://github.com/khoih-prog/WiFiNINA_Generic) and [**Blynk_WiFiNINA_WM**](https://github.com/khoih-prog/Blynk_WiFiNINA_WM) libraries.
48+
49+

examples/Argument_Complex/Argument_Complex.ino

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,6 @@
1111
The accuracy is nearly perfect compared to software timers. The most important feature is they're ISR-based timers
1212
Therefore, their executions are not blocked by bad-behaving functions / tasks.
1313
This important feature is absolutely necessary for mission-critical tasks.
14-
15-
Version: 1.3.0
16-
17-
Version Modified By Date Comments
18-
------- ----------- ---------- -----------
19-
1.0.0 K.Hoang 01/04/2021 Initial coding to support Arduino megaAVR ATmega4809-based boards (UNO WiFi Rev2, etc.)
20-
1.1.0 K.Hoang 14/04/2021 Fix bug. Don't use v1.0.0
21-
1.2.0 K.Hoang 17/04/2021 Selectable TCB Clock 16MHz, 8MHz or 250KHz depending on necessary accuracy
22-
1.3.0 K.Hoang 17/04/2021 Fix TCB Clock bug. Don't use v1.2.0
2314
*****************************************************************************************************************************/
2415

2516
// These define's must be placed at the beginning before #include "megaAVR_TimerInterrupt.h"

examples/Argument_None/Argument_None.ino

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,6 @@
1111
The accuracy is nearly perfect compared to software timers. The most important feature is they're ISR-based timers
1212
Therefore, their executions are not blocked by bad-behaving functions / tasks.
1313
This important feature is absolutely necessary for mission-critical tasks.
14-
15-
Version: 1.3.0
16-
17-
Version Modified By Date Comments
18-
------- ----------- ---------- -----------
19-
1.0.0 K.Hoang 01/04/2021 Initial coding to support Arduino megaAVR ATmega4809-based boards (UNO WiFi Rev2, etc.)
20-
1.1.0 K.Hoang 14/04/2021 Fix bug. Don't use v1.0.0
21-
1.2.0 K.Hoang 17/04/2021 Selectable TCB Clock 16MHz, 8MHz or 250KHz depending on necessary accuracy
22-
1.3.0 K.Hoang 17/04/2021 Fix TCB Clock bug. Don't use v1.2.0
2314
*****************************************************************************************************************************/
2415

2516
// These define's must be placed at the beginning before #include "megaAVR_TimerInterrupt.h"

examples/Argument_Simple/Argument_Simple.ino

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,6 @@
1111
The accuracy is nearly perfect compared to software timers. The most important feature is they're ISR-based timers
1212
Therefore, their executions are not blocked by bad-behaving functions / tasks.
1313
This important feature is absolutely necessary for mission-critical tasks.
14-
15-
Version: 1.3.0
16-
17-
Version Modified By Date Comments
18-
------- ----------- ---------- -----------
19-
1.0.0 K.Hoang 01/04/2021 Initial coding to support Arduino megaAVR ATmega4809-based boards (UNO WiFi Rev2, etc.)
20-
1.1.0 K.Hoang 14/04/2021 Fix bug. Don't use v1.0.0
21-
1.2.0 K.Hoang 17/04/2021 Selectable TCB Clock 16MHz, 8MHz or 250KHz depending on necessary accuracy
22-
1.3.0 K.Hoang 17/04/2021 Fix TCB Clock bug. Don't use v1.2.0
2314
*****************************************************************************************************************************/
2415

2516
// These define's must be placed at the beginning before #include "megaAVR_TimerInterrupt.h"

examples/Change_Interval/Change_Interval.ino

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,6 @@
1111
The accuracy is nearly perfect compared to software timers. The most important feature is they're ISR-based timers
1212
Therefore, their executions are not blocked by bad-behaving functions / tasks.
1313
This important feature is absolutely necessary for mission-critical tasks.
14-
15-
Version: 1.3.0
16-
17-
Version Modified By Date Comments
18-
------- ----------- ---------- -----------
19-
1.0.0 K.Hoang 01/04/2021 Initial coding to support Arduino megaAVR ATmega4809-based boards (UNO WiFi Rev2, etc.)
20-
1.1.0 K.Hoang 14/04/2021 Fix bug. Don't use v1.0.0
21-
1.2.0 K.Hoang 17/04/2021 Selectable TCB Clock 16MHz, 8MHz or 250KHz depending on necessary accuracy
22-
1.3.0 K.Hoang 17/04/2021 Fix TCB Clock bug. Don't use v1.2.0
2314
*****************************************************************************************************************************/
2415

2516
/*

0 commit comments

Comments
 (0)