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

Commit d8df380

Browse files
authored
v1.2.0
### Releases v1.2.0 1. Add better debug feature. 2. Optimize code and examples to reduce RAM usage 3. Add Table of Contents
1 parent 46a540a commit d8df380

27 files changed

+1559
-922
lines changed

README.md

Lines changed: 297 additions & 76 deletions
Large diffs are not rendered by default.

examples/Argument_None/Argument_None.ino

Lines changed: 47 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,33 @@
11
/****************************************************************************************************************************
2-
Argument_None.ino
3-
For NRF52 boards
4-
Written by Khoi Hoang
5-
6-
Built by Khoi Hoang https://github.com/khoih-prog/NRF52_TimerInterrupt
7-
Licensed under MIT license
8-
9-
Now even you use all these new 16 ISR-based timers,with their maximum interval practically unlimited (limited only by
10-
unsigned long miliseconds), you just consume only one NRF52 timer and avoid conflicting with other cores' tasks.
11-
The accuracy is nearly perfect compared to software timers. The most important feature is they're ISR-based timers
12-
Therefore, their executions are not blocked by bad-behaving functions / tasks.
13-
This important feature is absolutely necessary for mission-critical tasks.
14-
15-
Based on SimpleTimer - A timer library for Arduino.
16-
Author: mromani@ottotecnica.com
17-
Copyright (c) 2010 OTTOTECNICA Italy
18-
19-
Based on BlynkTimer.h
20-
Author: Volodymyr Shymanskyy
21-
22-
Version: 1.1.1
23-
24-
Version Modified By Date Comments
25-
------- ----------- ---------- -----------
26-
1.0.0 K Hoang 02/11/2020 Initial coding
27-
1.0.1 K Hoang 06/11/2020 Add complicated example ISR_16_Timers_Array using all 16 independent ISR Timers.
28-
1.0.2 K Hoang 24/11/2020 Add complicated example ISR_16_Timers_Array_Complex and optimize examples
29-
1.1.1 K.Hoang 06/12/2020 Add Change_Interval example. Bump up version to sync with other TimerInterrupt Libraries
2+
Argument_None.ino
3+
For NRF52 boards
4+
Written by Khoi Hoang
5+
6+
Built by Khoi Hoang https://github.com/khoih-prog/NRF52_TimerInterrupt
7+
Licensed under MIT license
8+
9+
Now even you use all these new 16 ISR-based timers,with their maximum interval practically unlimited (limited only by
10+
unsigned long miliseconds), you just consume only one NRF52 timer and avoid conflicting with other cores' tasks.
11+
The accuracy is nearly perfect compared to software timers. The most important feature is they're ISR-based timers
12+
Therefore, their executions are not blocked by bad-behaving functions / tasks.
13+
This important feature is absolutely necessary for mission-critical tasks.
14+
15+
Based on SimpleTimer - A timer library for Arduino.
16+
Author: mromani@ottotecnica.com
17+
Copyright (c) 2010 OTTOTECNICA Italy
18+
19+
Based on BlynkTimer.h
20+
Author: Volodymyr Shymanskyy
21+
22+
Version: 1.2.0
23+
24+
Version Modified By Date Comments
25+
------- ----------- ---------- -----------
26+
1.0.0 K Hoang 02/11/2020 Initial coding
27+
1.0.1 K Hoang 06/11/2020 Add complicated example ISR_16_Timers_Array using all 16 independent ISR Timers.
28+
1.0.2 K Hoang 24/11/2020 Add complicated example ISR_16_Timers_Array_Complex and optimize examples
29+
1.1.1 K.Hoang 06/12/2020 Add Change_Interval example. Bump up version to sync with other TimerInterrupt Libraries
30+
1.2.0 K.Hoang 11/01/2021 Add better debug feature. Optimize code and examples to reduce RAM usage
3031
*****************************************************************************************************************************/
3132

3233
/*
@@ -49,8 +50,11 @@
4950
#endif
5051

5152
// These define's must be placed at the beginning before #include "NRF52TimerInterrupt.h"
52-
// Don't define NRF52_TIMER_INTERRUPT_DEBUG > 2. Only for special ISR debugging only. Can hang the system.
53-
#define NRF52_TIMER_INTERRUPT_DEBUG 1
53+
// _TIMERINTERRUPT_LOGLEVEL_ from 0 to 4
54+
// Don't define _TIMERINTERRUPT_LOGLEVEL_ > 0. Only for special ISR debugging only. Can hang the system.
55+
// Don't define TIMER_INTERRUPT_DEBUG > 2. Only for special ISR debugging only. Can hang the system.
56+
#define TIMER_INTERRUPT_DEBUG 0
57+
#define _TIMERINTERRUPT_LOGLEVEL_ 0
5458

5559
#include "NRF52TimerInterrupt.h"
5660

@@ -86,10 +90,12 @@ volatile uint32_t Timer1Count = 0;
8690

8791
void printResult(uint32_t currTime)
8892
{
89-
Serial.printf("Time = %ld, Timer0Count = %lu, , Timer1Count = %lu\n", currTime, Timer0Count, Timer1Count);
93+
Serial.print(F("Time = ")); Serial.print(currTime);
94+
Serial.print(F(", Timer0Count = ")); Serial.print(Timer0Count);
95+
Serial.print(F(", Timer1Count = ")); Serial.println(Timer1Count);
9096
}
9197

92-
void TimerHandler0(void)
98+
void TimerHandler0()
9399
{
94100
static bool toggle0 = false;
95101

@@ -101,7 +107,7 @@ void TimerHandler0(void)
101107
toggle0 = !toggle0;
102108
}
103109

104-
void TimerHandler1(void)
110+
void TimerHandler1()
105111
{
106112
static bool toggle1 = false;
107113

@@ -122,26 +128,26 @@ void setup()
122128
while (!Serial);
123129

124130
delay(100);
125-
126-
Serial.printf("\nStarting Argument_None on %s\n", BOARD_NAME);
131+
132+
Serial.print(F("\nStarting Argument_None on ")); Serial.println(BOARD_NAME);
127133
Serial.println(NRF52_TIMER_INTERRUPT_VERSION);
128-
Serial.printf("CPU Frequency = %ld MHz\n", F_CPU / 1000000);
129-
134+
Serial.print(F("CPU Frequency = ")); Serial.print(F_CPU / 1000000); Serial.println(F(" MHz"));
135+
130136
// Interval in microsecs
131137
if (ITimer0.attachInterruptInterval(TIMER0_INTERVAL_MS * 1000, TimerHandler0))
132138
{
133-
Serial.printf("Starting ITimer0 OK, millis() = %ld\n", millis());
139+
Serial.print(F("Starting ITimer0 OK, millis() = ")); Serial.println(millis());
134140
}
135141
else
136-
Serial.println("Can't set ITimer0. Select another freq. or timer");
142+
Serial.println(F("Can't set ITimer0. Select another freq. or timer"));
137143

138144
// Interval in microsecs
139145
if (ITimer1.attachInterruptInterval(TIMER1_INTERVAL_MS * 1000, TimerHandler1))
140146
{
141-
Serial.printf("Starting ITimer1 OK, millis() = %ld\n", millis());
147+
Serial.print(F("Starting ITimer1 OK, millis() = ")); Serial.println(millis());
142148
}
143149
else
144-
Serial.println("Can't set ITimer1. Select another freq. or timer");
150+
Serial.println(F("Can't set ITimer1. Select another freq. or timer"));
145151
}
146152

147153
#define CHECK_INTERVAL_MS 10000L

examples/Change_Interval/Change_Interval.ino

Lines changed: 49 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,33 @@
11
/****************************************************************************************************************************
2-
Change_Interval.ino
3-
For NRF52 boards
4-
Written by Khoi Hoang
5-
6-
Built by Khoi Hoang https://github.com/khoih-prog/NRF52_TimerInterrupt
7-
Licensed under MIT license
8-
9-
Now even you use all these new 16 ISR-based timers,with their maximum interval practically unlimited (limited only by
10-
unsigned long miliseconds), you just consume only one NRF52 timer and avoid conflicting with other cores' tasks.
11-
The accuracy is nearly perfect compared to software timers. The most important feature is they're ISR-based timers
12-
Therefore, their executions are not blocked by bad-behaving functions / tasks.
13-
This important feature is absolutely necessary for mission-critical tasks.
14-
15-
Based on SimpleTimer - A timer library for Arduino.
16-
Author: mromani@ottotecnica.com
17-
Copyright (c) 2010 OTTOTECNICA Italy
18-
19-
Based on BlynkTimer.h
20-
Author: Volodymyr Shymanskyy
21-
22-
Version: 1.1.1
23-
24-
Version Modified By Date Comments
25-
------- ----------- ---------- -----------
26-
1.0.0 K Hoang 02/11/2020 Initial coding
27-
1.0.1 K Hoang 06/11/2020 Add complicated example ISR_16_Timers_Array using all 16 independent ISR Timers.
28-
1.0.2 K Hoang 24/11/2020 Add complicated example ISR_16_Timers_Array_Complex and optimize examples
29-
1.1.1 K.Hoang 06/12/2020 Add Change_Interval example. Bump up version to sync with other TimerInterrupt Libraries
2+
Change_Interval.ino
3+
For NRF52 boards
4+
Written by Khoi Hoang
5+
6+
Built by Khoi Hoang https://github.com/khoih-prog/NRF52_TimerInterrupt
7+
Licensed under MIT license
8+
9+
Now even you use all these new 16 ISR-based timers,with their maximum interval practically unlimited (limited only by
10+
unsigned long miliseconds), you just consume only one NRF52 timer and avoid conflicting with other cores' tasks.
11+
The accuracy is nearly perfect compared to software timers. The most important feature is they're ISR-based timers
12+
Therefore, their executions are not blocked by bad-behaving functions / tasks.
13+
This important feature is absolutely necessary for mission-critical tasks.
14+
15+
Based on SimpleTimer - A timer library for Arduino.
16+
Author: mromani@ottotecnica.com
17+
Copyright (c) 2010 OTTOTECNICA Italy
18+
19+
Based on BlynkTimer.h
20+
Author: Volodymyr Shymanskyy
21+
22+
Version: 1.2.0
23+
24+
Version Modified By Date Comments
25+
------- ----------- ---------- -----------
26+
1.0.0 K Hoang 02/11/2020 Initial coding
27+
1.0.1 K Hoang 06/11/2020 Add complicated example ISR_16_Timers_Array using all 16 independent ISR Timers.
28+
1.0.2 K Hoang 24/11/2020 Add complicated example ISR_16_Timers_Array_Complex and optimize examples
29+
1.1.1 K.Hoang 06/12/2020 Add Change_Interval example. Bump up version to sync with other TimerInterrupt Libraries
30+
1.2.0 K.Hoang 11/01/2021 Add better debug feature. Optimize code and examples to reduce RAM usage
3031
*****************************************************************************************************************************/
3132

3233
/*
@@ -49,8 +50,11 @@
4950
#endif
5051

5152
// These define's must be placed at the beginning before #include "NRF52TimerInterrupt.h"
52-
// Don't define NRF52_TIMER_INTERRUPT_DEBUG > 2. Only for special ISR debugging only. Can hang the system.
53-
#define NRF52_TIMER_INTERRUPT_DEBUG 0
53+
// _TIMERINTERRUPT_LOGLEVEL_ from 0 to 4
54+
// Don't define _TIMERINTERRUPT_LOGLEVEL_ > 0. Only for special ISR debugging only. Can hang the system.
55+
// Don't define TIMER_INTERRUPT_DEBUG > 2. Only for special ISR debugging only. Can hang the system.
56+
#define TIMER_INTERRUPT_DEBUG 0
57+
#define _TIMERINTERRUPT_LOGLEVEL_ 0
5458

5559
#include "NRF52TimerInterrupt.h"
5660

@@ -83,10 +87,12 @@ NRF52Timer ITimer1(NRF_TIMER_3);
8387

8488
void printResult(uint32_t currTime)
8589
{
86-
Serial.printf("Time = %ld, Timer0Count = %lu, , Timer1Count = %lu\n", currTime, Timer0Count, Timer1Count);
90+
Serial.print(F("Time = ")); Serial.print(currTime);
91+
Serial.print(F(", Timer0Count = ")); Serial.print(Timer0Count);
92+
Serial.print(F(", Timer1Count = ")); Serial.println(Timer1Count);
8793
}
8894

89-
void TimerHandler0(void)
95+
void TimerHandler0()
9096
{
9197
static bool toggle0 = false;
9298

@@ -98,7 +104,7 @@ void TimerHandler0(void)
98104
toggle0 = !toggle0;
99105
}
100106

101-
void TimerHandler1(void)
107+
void TimerHandler1()
102108
{
103109
static bool toggle1 = false;
104110

@@ -119,26 +125,26 @@ void setup()
119125
while (!Serial);
120126

121127
delay(100);
122-
123-
Serial.printf("\nStarting Change_Interval on %s\n", BOARD_NAME);
128+
129+
Serial.print(F("\nStarting Change_Interval on ")); Serial.println(BOARD_NAME);
124130
Serial.println(NRF52_TIMER_INTERRUPT_VERSION);
125-
Serial.printf("CPU Frequency = %ld MHz\n", F_CPU / 1000000);
131+
Serial.print(F("CPU Frequency = ")); Serial.print(F_CPU / 1000000); Serial.println(F(" MHz"));
126132

127133
// Interval in microsecs
128134
if (ITimer0.attachInterruptInterval(TIMER0_INTERVAL_MS * 1000, TimerHandler0))
129135
{
130-
Serial.printf("Starting ITimer0 OK, millis() = %ld\n", millis());
136+
Serial.print(F("Starting ITimer0 OK, millis() = ")); Serial.println(millis());
131137
}
132138
else
133-
Serial.println("Can't set ITimer0. Select another freq. or timer");
139+
Serial.println(F("Can't set ITimer0. Select another freq. or timer"));
134140

135141
// Interval in microsecs
136142
if (ITimer1.attachInterruptInterval(TIMER1_INTERVAL_MS * 1000, TimerHandler1))
137143
{
138-
Serial.printf("Starting ITimer1 OK, millis() = %ld\n", millis());
144+
Serial.print(F("Starting ITimer1 OK, millis() = ")); Serial.println(millis());
139145
}
140146
else
141-
Serial.println("Can't set ITimer1. Select another freq. or timer");
147+
Serial.println(F("Can't set ITimer1. Select another freq. or timer"));
142148
}
143149

144150
#define CHECK_INTERVAL_MS 10000L
@@ -166,8 +172,9 @@ void loop()
166172
ITimer0.setInterval(TIMER0_INTERVAL_MS * 1000 * (multFactor + 1), TimerHandler0);
167173
ITimer1.setInterval(TIMER1_INTERVAL_MS * 1000 * (multFactor + 1), TimerHandler1);
168174

169-
Serial.printf("Changing Interval, Timer0 = %lu, Timer1 = %lu\n", TIMER0_INTERVAL_MS * (multFactor + 1), TIMER1_INTERVAL_MS * (multFactor + 1));
170-
175+
Serial.print(F("Changing Interval, Timer0 = ")); Serial.print(TIMER0_INTERVAL_MS * (multFactor + 1));
176+
Serial.print(F(", Timer1 = ")); Serial.println(TIMER1_INTERVAL_MS * (multFactor + 1));
177+
171178
lastChangeTime = currTime;
172179
}
173180
}

0 commit comments

Comments
 (0)