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

Commit dfdae9b

Browse files
authored
v1.2.0
### Release v1.2.0 1. Selectable **TCB Clock 16MHz, 8MHz or 250KHz** depending on necessary accuracy 2. Add BOARD_NAME definition
1 parent ba1a2f5 commit dfdae9b

34 files changed

+920
-154
lines changed

README.md

Lines changed: 305 additions & 7 deletions
Large diffs are not rendered by default.

examples/Argument_Complex/Argument_Complex.ino

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,13 @@
1212
Therefore, their executions are not blocked by bad-behaving functions / tasks.
1313
This important feature is absolutely necessary for mission-critical tasks.
1414
15-
Version: 1.0.0
15+
Version: 1.2.0
1616
1717
Version Modified By Date Comments
1818
------- ----------- ---------- -----------
1919
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
2022
*****************************************************************************************************************************/
2123

2224
// These define's must be placed at the beginning before #include "megaAVR_TimerInterrupt.h"
@@ -25,6 +27,14 @@
2527
#define TIMER_INTERRUPT_DEBUG 0
2628
#define _TIMERINTERRUPT_LOGLEVEL_ 0
2729

30+
// Select USING_16MHZ == true for 16MHz to Timer TCBx => shorter timer, but better accuracy
31+
// Select USING_8MHZ == true for 8MHz to Timer TCBx => shorter timer, but better accuracy
32+
// Select USING_250KHZ == true for 250KHz to Timer TCBx => shorter timer, but better accuracy
33+
// Not select for default 250KHz to Timer TCBx => longer timer, but worse accuracy
34+
#define USING_16MHZ true
35+
#define USING_8MHZ false
36+
#define USING_250KHZ false
37+
2838
#define USE_TIMER_0 false
2939
#define USE_TIMER_1 true
3040
#define USE_TIMER_2 false
@@ -85,10 +95,21 @@ void setup()
8595
Serial.begin(115200);
8696
while (!Serial);
8797

88-
Serial.println(F("\nStarting Argument_Complex on megaAVR"));
98+
Serial.print(F("\nStarting Argument_Complex on "));
99+
Serial.println(BOARD_NAME);
89100
Serial.println(MEGA_AVR_TIMER_INTERRUPT_VERSION);
90101
Serial.print(F("CPU Frequency = ")); Serial.print(F_CPU / 1000000); Serial.println(F(" MHz"));
91102

103+
Serial.print(F("TCB Clock Frequency = "));
104+
105+
#if USING_16MHZ
106+
Serial.println(F("16MHz for highest accuracy"));
107+
#elif USING_8MHZ
108+
Serial.println(F("8MHz for very high accuracy"));
109+
#else
110+
Serial.println(F("250KHz for lower accuracy but longer time"));
111+
#endif
112+
92113
// Timer0 is used for micros(), millis(), delay(), etc and can't be used
93114
// Select Timer 1-2 for UNO, 0-5 for MEGA
94115
// Timer 2 is 8-bit timer, only for higher frequency

examples/Argument_None/Argument_None.ino

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,13 @@
1212
Therefore, their executions are not blocked by bad-behaving functions / tasks.
1313
This important feature is absolutely necessary for mission-critical tasks.
1414
15-
Version: 1.0.0
15+
Version: 1.2.0
1616
1717
Version Modified By Date Comments
1818
------- ----------- ---------- -----------
1919
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
2022
*****************************************************************************************************************************/
2123

2224
// These define's must be placed at the beginning before #include "megaAVR_TimerInterrupt.h"
@@ -25,6 +27,14 @@
2527
#define TIMER_INTERRUPT_DEBUG 0
2628
#define _TIMERINTERRUPT_LOGLEVEL_ 0
2729

30+
// Select USING_16MHZ == true for 16MHz to Timer TCBx => shorter timer, but better accuracy
31+
// Select USING_8MHZ == true for 8MHz to Timer TCBx => shorter timer, but better accuracy
32+
// Select USING_250KHZ == true for 250KHz to Timer TCBx => shorter timer, but better accuracy
33+
// Not select for default 250KHz to Timer TCBx => longer timer, but worse accuracy
34+
#define USING_16MHZ true
35+
#define USING_8MHZ false
36+
#define USING_250KHZ false
37+
2838
#define USE_TIMER_0 false
2939
#define USE_TIMER_1 true
3040
#define USE_TIMER_2 false
@@ -80,10 +90,21 @@ void setup()
8090
Serial.begin(115200);
8191
while (!Serial);
8292

83-
Serial.println(F("\nStarting Argument_None on megaAVR"));
93+
Serial.print(F("\nStarting Argument_None on "));
94+
Serial.println(BOARD_NAME);
8495
Serial.println(MEGA_AVR_TIMER_INTERRUPT_VERSION);
8596
Serial.print(F("CPU Frequency = ")); Serial.print(F_CPU / 1000000); Serial.println(F(" MHz"));
8697

98+
Serial.print(F("TCB Clock Frequency = "));
99+
100+
#if USING_16MHZ
101+
Serial.println(F("16MHz for highest accuracy"));
102+
#elif USING_8MHZ
103+
Serial.println(F("8MHz for very high accuracy"));
104+
#else
105+
Serial.println(F("250KHz for lower accuracy but longer time"));
106+
#endif
107+
87108
// Select Timer 1-2 for UNO, 0-5 for MEGA
88109
// Timer 2 is 8-bit timer, only for higher frequency
89110
ITimer1.init();

examples/Argument_Simple/Argument_Simple.ino

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,13 @@
1212
Therefore, their executions are not blocked by bad-behaving functions / tasks.
1313
This important feature is absolutely necessary for mission-critical tasks.
1414
15-
Version: 1.0.0
15+
Version: 1.2.0
1616
1717
Version Modified By Date Comments
1818
------- ----------- ---------- -----------
1919
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
2022
*****************************************************************************************************************************/
2123

2224
// These define's must be placed at the beginning before #include "megaAVR_TimerInterrupt.h"
@@ -25,6 +27,14 @@
2527
#define TIMER_INTERRUPT_DEBUG 0
2628
#define _TIMERINTERRUPT_LOGLEVEL_ 0
2729

30+
// Select USING_16MHZ == true for 16MHz to Timer TCBx => shorter timer, but better accuracy
31+
// Select USING_8MHZ == true for 8MHz to Timer TCBx => shorter timer, but better accuracy
32+
// Select USING_250KHZ == true for 250KHz to Timer TCBx => shorter timer, but better accuracy
33+
// Not select for default 250KHz to Timer TCBx => longer timer, but worse accuracy
34+
#define USING_16MHZ true
35+
#define USING_8MHZ false
36+
#define USING_250KHZ false
37+
2838
#define USE_TIMER_0 false
2939
#define USE_TIMER_1 true
3040
#define USE_TIMER_2 false
@@ -88,10 +98,21 @@ void setup()
8898
Serial.begin(115200);
8999
while (!Serial);
90100

91-
Serial.println(F("\nStarting Argument_Simple on megaAVR"));
101+
Serial.print(F("\nStarting Argument_Simple on "));
102+
Serial.println(BOARD_NAME);
92103
Serial.println(MEGA_AVR_TIMER_INTERRUPT_VERSION);
93104
Serial.print(F("CPU Frequency = ")); Serial.print(F_CPU / 1000000); Serial.println(F(" MHz"));
94105

106+
Serial.print(F("TCB Clock Frequency = "));
107+
108+
#if USING_16MHZ
109+
Serial.println(F("16MHz for highest accuracy"));
110+
#elif USING_8MHZ
111+
Serial.println(F("8MHz for very high accuracy"));
112+
#else
113+
Serial.println(F("250KHz for lower accuracy but longer time"));
114+
#endif
115+
95116
// Timer0 is used for micros(), millis(), delay(), etc and can't be used
96117
// Select Timer 1-2 for UNO, 0-5 for MEGA
97118
// Timer 2 is 8-bit timer, only for higher frequency

examples/Change_Interval/Change_Interval.ino

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,13 @@
1212
Therefore, their executions are not blocked by bad-behaving functions / tasks.
1313
This important feature is absolutely necessary for mission-critical tasks.
1414
15-
Version: 1.0.0
15+
Version: 1.2.0
1616
1717
Version Modified By Date Comments
1818
------- ----------- ---------- -----------
1919
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
2022
*****************************************************************************************************************************/
2123

2224
/*
@@ -37,6 +39,14 @@
3739
#define TIMER_INTERRUPT_DEBUG 0
3840
#define _TIMERINTERRUPT_LOGLEVEL_ 0
3941

42+
// Select USING_16MHZ == true for 16MHz to Timer TCBx => shorter timer, but better accuracy
43+
// Select USING_8MHZ == true for 8MHz to Timer TCBx => shorter timer, but better accuracy
44+
// Select USING_250KHZ == true for 250KHz to Timer TCBx => shorter timer, but better accuracy
45+
// Not select for default 250KHz to Timer TCBx => longer timer, but worse accuracy
46+
#define USING_16MHZ true
47+
#define USING_8MHZ false
48+
#define USING_250KHZ false
49+
4050
#define USE_TIMER_0 false
4151
#define USE_TIMER_1 true
4252
#define USE_TIMER_2 true
@@ -102,10 +112,21 @@ void setup()
102112
Serial.begin(115200);
103113
while (!Serial);
104114

105-
Serial.println(F("\nStarting Change_Interval on megaAVR"));
115+
Serial.print(F("\nStarting Change_Interval on "));
116+
Serial.println(BOARD_NAME);
106117
Serial.println(MEGA_AVR_TIMER_INTERRUPT_VERSION);
107118
Serial.print(F("CPU Frequency = ")); Serial.print(F_CPU / 1000000); Serial.println(F(" MHz"));
108119

120+
Serial.print(F("TCB Clock Frequency = "));
121+
122+
#if USING_16MHZ
123+
Serial.println(F("16MHz for highest accuracy"));
124+
#elif USING_8MHZ
125+
Serial.println(F("8MHz for very high accuracy"));
126+
#else
127+
Serial.println(F("250KHz for lower accuracy but longer time"));
128+
#endif
129+
109130

110131
// Select Timer 1-2 for UNO, 0-5 for MEGA
111132
// Timer 2 is 8-bit timer, only for higher frequency

examples/FakeAnalogWrite/FakeAnalogWrite.ino

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,13 @@
1212
Therefore, their executions are not blocked by bad-behaving functions / tasks.
1313
This important feature is absolutely necessary for mission-critical tasks.
1414
15-
Version: 1.0.0
15+
Version: 1.2.0
1616
1717
Version Modified By Date Comments
1818
------- ----------- ---------- -----------
1919
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
2022
*****************************************************************************************************************************/
2123
/*
2224
Notes:
@@ -46,6 +48,14 @@
4648

4749
#define LOCAL_DEBUG 1
4850

51+
// Select USING_16MHZ == true for 16MHz to Timer TCBx => shorter timer, but better accuracy
52+
// Select USING_8MHZ == true for 8MHz to Timer TCBx => shorter timer, but better accuracy
53+
// Select USING_250KHZ == true for 250KHz to Timer TCBx => shorter timer, but better accuracy
54+
// Not select for default 250KHz to Timer TCBx => longer timer, but worse accuracy
55+
#define USING_16MHZ true
56+
#define USING_8MHZ false
57+
#define USING_250KHZ false
58+
4959
#define USE_TIMER_0 false
5060
#define USE_TIMER_1 true
5161
#define USE_TIMER_2 false
@@ -183,10 +193,21 @@ void setup()
183193
Serial.begin(115200);
184194
while (!Serial);
185195

186-
Serial.println(F("\nStarting FakeAnalogWrite on megaAVR"));
196+
Serial.print(F("\nStarting FakeAnalogWrite on "));
197+
Serial.println(BOARD_NAME);
187198
Serial.println(MEGA_AVR_TIMER_INTERRUPT_VERSION);
188199
Serial.print(F("CPU Frequency = ")); Serial.print(F_CPU / 1000000); Serial.println(F(" MHz"));
189200

201+
Serial.print(F("TCB Clock Frequency = "));
202+
203+
#if USING_16MHZ
204+
Serial.println(F("16MHz for highest accuracy"));
205+
#elif USING_8MHZ
206+
Serial.println(F("8MHz for very high accuracy"));
207+
#else
208+
Serial.println(F("250KHz for lower accuracy but longer time"));
209+
#endif
210+
190211
ITimer1.init();
191212

192213
//if (ITimer1.attachInterruptInterval(TIMER2_INTERVAL_MS, TimerHandler))

examples/ISR_16_Timers_Array_Complex/ISR_16_Timers_Array_Complex.ino

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,13 @@
1212
Therefore, their executions are not blocked by bad-behaving functions / tasks.
1313
This important feature is absolutely necessary for mission-critical tasks.
1414
15-
Version: 1.0.0
15+
Version: 1.2.0
1616
1717
Version Modified By Date Comments
1818
------- ----------- ---------- -----------
1919
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
2022
*****************************************************************************************************************************/
2123

2224
// These define's must be placed at the beginning before #include "megaAVR_TimerInterrupt.h"
@@ -25,6 +27,15 @@
2527
#define TIMER_INTERRUPT_DEBUG 0
2628
#define _TIMERINTERRUPT_LOGLEVEL_ 0
2729

30+
// Select USING_16MHZ == true for 16MHz to Timer TCBx => shorter timer, but better accuracy
31+
// Select USING_8MHZ == true for 8MHz to Timer TCBx => shorter timer, but better accuracy
32+
// Select USING_250KHZ == true for 250KHz to Timer TCBx => shorter timer, but better accuracy
33+
// Not select for default 250KHz to Timer TCBx => longer timer, but worse accuracy
34+
#define USING_16MHZ true
35+
#define USING_8MHZ false
36+
#define USING_250KHZ false
37+
38+
2839
#define USE_TIMER_0 false
2940
#define USE_TIMER_1 true
3041
#define USE_TIMER_2 true
@@ -287,10 +298,21 @@ void setup()
287298
Serial.begin(115200);
288299
while (!Serial);
289300

290-
Serial.println(F("\nStarting ISR_16_Timers_Array_Complex on megaAVR"));
301+
Serial.print(F("\nStarting ISR_16_Timers_Array_Complex on "));
302+
Serial.println(BOARD_NAME);
291303
Serial.println(MEGA_AVR_TIMER_INTERRUPT_VERSION);
292304
Serial.print(F("CPU Frequency = ")); Serial.print(F_CPU / 1000000); Serial.println(F(" MHz"));
293305

306+
Serial.print(F("TCB Clock Frequency = "));
307+
308+
#if USING_16MHZ
309+
Serial.println(F("16MHz for highest accuracy"));
310+
#elif USING_8MHZ
311+
Serial.println(F("8MHz for very high accuracy"));
312+
#else
313+
Serial.println(F("250KHz for lower accuracy but longer time"));
314+
#endif
315+
294316
ITimer1.init();
295317

296318
if (ITimer1.attachInterruptInterval(TIMER1_INTERVAL_MS, TimerHandler1))

examples/ISR_RPM_Measure/ISR_RPM_Measure.ino

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,13 @@
1212
Therefore, their executions are not blocked by bad-behaving functions / tasks.
1313
This important feature is absolutely necessary for mission-critical tasks.
1414
15-
Version: 1.0.0
15+
Version: 1.2.0
1616
1717
Version Modified By Date Comments
1818
------- ----------- ---------- -----------
1919
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
2022
*****************************************************************************************************************************/
2123
/* RPM Measuring uses high frequency hardware timer 1Hz == 1ms) to measure the time from of one rotation, in ms
2224
then convert to RPM. One rotation is detected by reading the state of a magnetic REED SW or IR LED Sensor
@@ -35,6 +37,14 @@
3537
#define TIMER_INTERRUPT_DEBUG 0
3638
#define _TIMERINTERRUPT_LOGLEVEL_ 0
3739

40+
// Select USING_16MHZ == true for 16MHz to Timer TCBx => shorter timer, but better accuracy
41+
// Select USING_8MHZ == true for 8MHz to Timer TCBx => shorter timer, but better accuracy
42+
// Select USING_250KHZ == true for 250KHz to Timer TCBx => shorter timer, but better accuracy
43+
// Not select for default 250KHz to Timer TCBx => longer timer, but worse accuracy
44+
#define USING_16MHZ true
45+
#define USING_8MHZ false
46+
#define USING_250KHZ false
47+
3848
#define USE_TIMER_0 false
3949
#define USE_TIMER_1 true
4050
#define USE_TIMER_2 true
@@ -122,10 +132,21 @@ void setup()
122132
Serial.begin(115200);
123133
while (!Serial);
124134

125-
Serial.println(F("\nStarting ISR_RPM_Measure on megaAVR"));
135+
Serial.print(F("\nStarting ISR_RPM_Measure on "));
136+
Serial.println(BOARD_NAME);
126137
Serial.println(MEGA_AVR_TIMER_INTERRUPT_VERSION);
127138
Serial.print(F("CPU Frequency = ")); Serial.print(F_CPU / 1000000); Serial.println(F(" MHz"));
128139

140+
Serial.print(F("TCB Clock Frequency = "));
141+
142+
#if USING_16MHZ
143+
Serial.println(F("16MHz for highest accuracy"));
144+
#elif USING_8MHZ
145+
Serial.println(F("8MHz for very high accuracy"));
146+
#else
147+
Serial.println(F("250KHz for lower accuracy but longer time"));
148+
#endif
149+
129150
pinMode(LED_BUILTIN, OUTPUT);
130151
pinMode(interruptPin, INPUT_PULLUP);
131152

0 commit comments

Comments
 (0)