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

Commit e844b26

Browse files
authored
v1.0.1 for bug related to TCB0
### Initial Release v1.0.1 1. Fix bug giving error when using TCB0 (`USE_TIMER_0 == true`) 2. Default to use TCB0 for boards having only 1 TCB Timer, such as `ATtiny817`, `ATtiny807`
1 parent 24273fb commit e844b26

File tree

24 files changed

+60
-47
lines changed

24 files changed

+60
-47
lines changed

changelog.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,19 @@
99
## Table of Contents
1010

1111
* [Changelog](#changelog)
12+
* [Release v1.0.1](#release-v101)
1213
* [Initial Release v1.0.0](#initial-release-v100)
1314

1415
---
1516
---
1617

1718
## Changelog
1819

20+
### Initial Release v1.0.1
21+
22+
1. Fix bug giving error when using TCB0 (`USE_TIMER_0 == true`)
23+
2. Default to use TCB0 for boards having only 1 TCB Timer, such as `ATtiny817`, `ATtiny807`
24+
1925
### Initial Release v1.0.0
2026

2127
1. Intial release to support Arduino **AVR ATtiny-based boards (ATtiny3217, etc.) using megaTinyCore**

examples/Argument_Complex/Argument_Complex.ino

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@
3535
#define USING_250KHZ false // Not supported now
3636

3737
// Try to use RTC, TCA0 or TCD0 for millis()
38-
#define USE_TIMER_0 false // Check if used by millis(), Servo or tone()
39-
#define USE_TIMER_1 true // Check if used by millis(), Servo or tone()
38+
#define USE_TIMER_0 true // Check if used by millis(), Servo or tone()
39+
#define USE_TIMER_1 false // Check if used by millis(), Servo or tone()
4040

4141
#if USE_TIMER_0
4242
#define CurrentTimer ITimer0

examples/Argument_None/Argument_None.ino

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@
3535
#define USING_250KHZ false // Not supported now
3636

3737
// Try to use RTC, TCA0 or TCD0 for millis()
38-
#define USE_TIMER_0 false // Check if used by millis(), Servo or tone()
39-
#define USE_TIMER_1 true // Check if used by millis(), Servo or tone()
38+
#define USE_TIMER_0 true // Check if used by millis(), Servo or tone()
39+
#define USE_TIMER_1 false // Check if used by millis(), Servo or tone()
4040

4141
#if USE_TIMER_0
4242
#define CurrentTimer ITimer0

examples/Argument_Simple/Argument_Simple.ino

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@
3535
#define USING_250KHZ false // Not supported now
3636

3737
// Try to use RTC, TCA0 or TCD0 for millis()
38-
#define USE_TIMER_0 false // Check if used by millis(), Servo or tone()
39-
#define USE_TIMER_1 true // Check if used by millis(), Servo or tone()
38+
#define USE_TIMER_0 true // Check if used by millis(), Servo or tone()
39+
#define USE_TIMER_1 false // Check if used by millis(), Servo or tone()
4040

4141
#if USE_TIMER_0
4242
#define CurrentTimer ITimer0

examples/Change_Interval/Change_Interval.ino

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@
3535
#define USING_250KHZ false // Not supported now
3636

3737
// Try to use RTC, TCA0 or TCD0 for millis()
38-
#define USE_TIMER_0 false // Check if used by millis(), Servo or tone()
39-
#define USE_TIMER_1 true // Check if used by millis(), Servo or tone()
38+
#define USE_TIMER_0 true // Check if used by millis(), Servo or tone()
39+
#define USE_TIMER_1 false // Check if used by millis(), Servo or tone()
4040

4141
#if USE_TIMER_0
4242
#define CurrentTimer ITimer0

examples/Change_Interval_HF/Change_Interval_HF.ino

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@
3535
#define USING_250KHZ false // Not supported now
3636

3737
// Try to use RTC, TCA0 or TCD0 for millis()
38-
#define USE_TIMER_0 false // Check if used by millis(), Servo or tone()
39-
#define USE_TIMER_1 true // Check if used by millis(), Servo or tone()
38+
#define USE_TIMER_0 true // Check if used by millis(), Servo or tone()
39+
#define USE_TIMER_1 false // Check if used by millis(), Servo or tone()
4040

4141
#if USE_TIMER_0
4242
#define CurrentTimer ITimer0

examples/FakeAnalogWrite/FakeAnalogWrite.ino

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@
3535
#define USING_250KHZ false // Not supported now
3636

3737
// Try to use RTC, TCA0 or TCD0 for millis()
38-
#define USE_TIMER_0 false // Check if used by millis(), Servo or tone()
39-
#define USE_TIMER_1 true // Check if used by millis(), Servo or tone()
38+
#define USE_TIMER_0 true // Check if used by millis(), Servo or tone()
39+
#define USE_TIMER_1 false // Check if used by millis(), Servo or tone()
4040

4141
#if USE_TIMER_0
4242
#define CurrentTimer ITimer0

examples/ISR_16_Timers_Array_Complex/ISR_16_Timers_Array_Complex.ino

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,13 @@
3030
// Select USING_HALF_CLOCK == true for 10/ 8MHz to Timer TCBx => shorter timer, but better accuracy
3131
// Select USING_250KHZ == true for 250KHz to Timer TCBx => longer timer, but worse accuracy
3232
// Not select for default 250KHz to Timer TCBx => longer timer, but worse accuracy
33-
#define USING_FULL_CLOCK false
34-
#define USING_HALF_CLOCK true
33+
#define USING_FULL_CLOCK true
34+
#define USING_HALF_CLOCK false
3535
#define USING_250KHZ false // Not supported now
3636

3737
// Try to use RTC, TCA0 or TCD0 for millis()
38-
#define USE_TIMER_0 false // Check if used by millis(), Servo or tone()
39-
#define USE_TIMER_1 true // Check if used by millis(), Servo or tone()
38+
#define USE_TIMER_0 true // Check if used by millis(), Servo or tone()
39+
#define USE_TIMER_1 false // Check if used by millis(), Servo or tone()
4040

4141
#if USE_TIMER_0
4242
#define CurrentTimer ITimer0

examples/ISR_RPM_Measure/ISR_RPM_Measure.ino

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@
3535
#define USING_250KHZ false // Not supported now
3636

3737
// Try to use RTC, TCA0 or TCD0 for millis()
38-
#define USE_TIMER_0 false // Check if used by millis(), Servo or tone()
39-
#define USE_TIMER_1 true // Check if used by millis(), Servo or tone()
38+
#define USE_TIMER_0 true // Check if used by millis(), Servo or tone()
39+
#define USE_TIMER_1 false // Check if used by millis(), Servo or tone()
4040

4141
#if USE_TIMER_0
4242
#define CurrentTimer ITimer0

examples/ISR_Timers_Array_Simple/ISR_Timers_Array_Simple.ino

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@
3535
#define USING_250KHZ false // Not supported now
3636

3737
// Try to use RTC, TCA0 or TCD0 for millis()
38-
#define USE_TIMER_0 false // Check if used by millis(), Servo or tone()
39-
#define USE_TIMER_1 true // Check if used by millis(), Servo or tone()
38+
#define USE_TIMER_0 true // Check if used by millis(), Servo or tone()
39+
#define USE_TIMER_1 false // Check if used by millis(), Servo or tone()
4040

4141
#if USE_TIMER_0
4242
#define CurrentTimer ITimer0

examples/RPM_Measure/RPM_Measure.ino

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,8 @@
4545
#define USING_250KHZ false // Not supported now
4646

4747
// Try to use RTC, TCA0 or TCD0 for millis()
48-
#define USE_TIMER_0 false // Check if used by millis(), Servo or tone()
49-
#define USE_TIMER_1 true // Check if used by millis(), Servo or tone()
48+
#define USE_TIMER_0 true // Check if used by millis(), Servo or tone()
49+
#define USE_TIMER_1 false // Check if used by millis(), Servo or tone()
5050

5151
#if USE_TIMER_0
5252
#define CurrentTimer ITimer0

examples/SwitchDebounce/SwitchDebounce.ino

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,8 @@
4242
#define USING_250KHZ false // Not supported now
4343

4444
// Try to use RTC, TCA0 or TCD0 for millis()
45-
#define USE_TIMER_0 false // Check if used by millis(), Servo or tone()
46-
#define USE_TIMER_1 true // Check if used by millis(), Servo or tone()
45+
#define USE_TIMER_0 true // Check if used by millis(), Servo or tone()
46+
#define USE_TIMER_1 false // Check if used by millis(), Servo or tone()
4747

4848
#if USE_TIMER_0
4949
#define CurrentTimer ITimer0

examples/TimerDuration/TimerDuration.ino

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@
3535
#define USING_250KHZ false // Not supported now
3636

3737
// Try to use RTC, TCA0 or TCD0 for millis()
38-
#define USE_TIMER_0 false // Check if used by millis(), Servo or tone()
39-
#define USE_TIMER_1 true // Check if used by millis(), Servo or tone()
38+
#define USE_TIMER_0 true // Check if used by millis(), Servo or tone()
39+
#define USE_TIMER_1 false // Check if used by millis(), Servo or tone()
4040

4141
#if USE_TIMER_0
4242
#define CurrentTimer ITimer0

examples/TimerInterruptTest/TimerInterruptTest.ino

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@
3535
#define USING_250KHZ false // Not supported now
3636

3737
// Try to use RTC, TCA0 or TCD0 for millis()
38-
#define USE_TIMER_0 false // Check if used by millis(), Servo or tone()
39-
#define USE_TIMER_1 true // Check if used by millis(), Servo or tone()
38+
#define USE_TIMER_0 true // Check if used by millis(), Servo or tone()
39+
#define USE_TIMER_1 false // Check if used by millis(), Servo or tone()
4040

4141
#if USE_TIMER_0
4242
#define CurrentTimer ITimer0

examples/multiFileProject/multiFileProject.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@
3434
#define USING_250KHZ false // Not supported now
3535

3636
// Try to use RTC, TCA0 or TCD0 for millis()
37-
#define USE_TIMER_0 false // Check if used by millis(), Servo or tone()
38-
#define USE_TIMER_1 true // Check if used by millis(), Servo or tone()
37+
#define USE_TIMER_0 true // Check if used by millis(), Servo or tone()
38+
#define USE_TIMER_1 false // Check if used by millis(), Servo or tone()
3939

4040
#if USE_TIMER_0
4141
#define CurrentTimer ITimer0

library.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "ATtiny_TimerInterrupt",
3-
"version": "1.0.0",
3+
"version": "1.0.1",
44
"keywords": "timer, interrupt, isr, isr-based, timing, control, hardware-timer, mission-critical, accuracy, megaavr, avr-attiny, attiny, megatinycore, megatiny-core, attiny-timerinterrupt, tcb-timers",
55
"description": "This library enables you to use Interrupt from Hardware Timers on Arduino AVR ATtiny-based boards (ATtiny3217, etc.) using megaTinyCore. These ATtiny 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 is mandatory if you need to measure some data requiring better accuracy. It now supports 16 ISR-based Timers, while consuming only 1 Hardware Timer. Timers interval is very long (ulong millisecs). The most important feature is they are ISR-based Timers. Therefore, their executions are not blocked by bad-behaving functions or tasks. This important feature is absolutely necessary for mission-critical tasks",
66
"authors":

library.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name=ATtiny_TimerInterrupt
2-
version=1.0.0
2+
version=1.0.1
33
author=Khoi Hoang
44
maintainer=Khoi Hoang <khoih.prog@gmail.com>
55
sentence=This library enables you to use Interrupt from Hardware Timers on Arduino AVR ATtiny-based boards (ATtiny3217, etc.) using megaTinyCore

src/ATtiny_ISR_Timer.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,12 @@
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.0.1
1616
1717
Version Modified By Date Comments
1818
------- ----------- ---------- -----------
1919
1.0.0 K.Hoang 27/08/2022 Initial coding to support AVR ATtiny (ATtiny3217, etc.) using megaTinyCore
20+
1.0.1 K.Hoang 27/08/2022 Fix TCB0 disable bug
2021
*****************************************************************************************************************************/
2122

2223
#pragma once

src/ATtiny_ISR_Timer.hpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,12 @@
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.0.1
1616
1717
Version Modified By Date Comments
1818
------- ----------- ---------- -----------
1919
1.0.0 K.Hoang 27/08/2022 Initial coding to support AVR ATtiny (ATtiny3217, etc.) using megaTinyCore
20+
1.0.1 K.Hoang 27/08/2022 Fix TCB0 disable bug
2021
*****************************************************************************************************************************/
2122

2223
#pragma once
@@ -31,13 +32,13 @@
3132
#endif
3233

3334
#ifndef AT_TINY_TIMER_INTERRUPT_VERSION
34-
#define AT_TINY_TIMER_INTERRUPT_VERSION F("ATtiny_TimerInterrupt v1.0.0")
35+
#define AT_TINY_TIMER_INTERRUPT_VERSION F("ATtiny_TimerInterrupt v1.0.1")
3536

3637
#define AT_TINY_TIMER_INTERRUPT_VERSION_MAJOR 1
3738
#define AT_TINY_TIMER_INTERRUPT_VERSION_MINOR 0
38-
#define AT_TINY_TIMER_INTERRUPT_VERSION_PATCH 0
39+
#define AT_TINY_TIMER_INTERRUPT_VERSION_PATCH 1
3940

40-
#define AT_TINY_TIMER_INTERRUPT_VERSION_INT 1000000
41+
#define AT_TINY_TIMER_INTERRUPT_VERSION_INT 1000001
4142
#endif
4243

4344
#include "TimerInterrupt_Generic_Debug.h"

src/ATtiny_ISR_Timer_Impl.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,12 @@
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.0.1
1616
1717
Version Modified By Date Comments
1818
------- ----------- ---------- -----------
1919
1.0.0 K.Hoang 27/08/2022 Initial coding to support AVR ATtiny (ATtiny3217, etc.) using megaTinyCore
20+
1.0.1 K.Hoang 27/08/2022 Fix TCB0 disable bug
2021
*****************************************************************************************************************************/
2122

2223
#pragma once

src/ATtiny_TimerInterrupt.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,12 @@
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.0.1
1616
1717
Version Modified By Date Comments
1818
------- ----------- ---------- -----------
1919
1.0.0 K.Hoang 27/08/2022 Initial coding to support AVR ATtiny (ATtiny3217, etc.) using megaTinyCore
20+
1.0.1 K.Hoang 27/08/2022 Fix TCB0 disable bug
2021
****************************************************************************************************************************/
2122

2223
#pragma once

src/ATtiny_TimerInterrupt.hpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,12 @@
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.0.1
1616
1717
Version Modified By Date Comments
1818
------- ----------- ---------- -----------
1919
1.0.0 K.Hoang 27/08/2022 Initial coding to support AVR ATtiny (ATtiny3217, etc.) using megaTinyCore
20+
1.0.1 K.Hoang 27/08/2022 Fix TCB0 disable bug
2021
****************************************************************************************************************************/
2122

2223
#pragma once
@@ -155,13 +156,13 @@
155156
#include "TimerInterrupt_Generic_Debug.h"
156157

157158
#ifndef AT_TINY_TIMER_INTERRUPT_VERSION
158-
#define AT_TINY_TIMER_INTERRUPT_VERSION F("ATtiny_TimerInterrupt v1.0.0")
159+
#define AT_TINY_TIMER_INTERRUPT_VERSION F("ATtiny_TimerInterrupt v1.0.1")
159160

160161
#define AT_TINY_TIMER_INTERRUPT_VERSION_MAJOR 1
161162
#define AT_TINY_TIMER_INTERRUPT_VERSION_MINOR 0
162-
#define AT_TINY_TIMER_INTERRUPT_VERSION_PATCH 0
163+
#define AT_TINY_TIMER_INTERRUPT_VERSION_PATCH 1
163164

164-
#define AT_TINY_TIMER_INTERRUPT_VERSION_INT 1000000
165+
#define AT_TINY_TIMER_INTERRUPT_VERSION_INT 1000001
165166
#endif
166167

167168
#include <avr/interrupt.h>

src/ATtiny_TimerInterrupt_Impl.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,12 @@
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.0.1
1616
1717
Version Modified By Date Comments
1818
------- ----------- ---------- -----------
1919
1.0.0 K.Hoang 27/08/2022 Initial coding to support AVR ATtiny (ATtiny3217, etc.) using megaTinyCore
20+
1.0.1 K.Hoang 27/08/2022 Fix TCB0 disable bug
2021
****************************************************************************************************************************/
2122

2223
#pragma once
@@ -194,8 +195,8 @@ bool TimerInterrupt::setFrequency(const float& frequency, timer_callback_p callb
194195
float frequencyLimit = frequency * 17179.840;
195196

196197
// Limit frequency to larger than (0.00372529 / 64) Hz or interval 17179.840s / 17179840 ms to avoid uint32_t overflow
197-
if ((_timer <= 0) || (callback == NULL) || ((frequencyLimit) < 1) )
198-
{
198+
if ((_timer < 0) || (callback == NULL) || ((frequencyLimit) < 1) )
199+
{
199200
return false;
200201
}
201202
else

src/TimerInterrupt_Generic_Debug.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,12 @@
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.0.1
1616
1717
Version Modified By Date Comments
1818
------- ----------- ---------- -----------
1919
1.0.0 K.Hoang 27/08/2022 Initial coding to support AVR ATtiny (ATtiny3217, etc.) using megaTinyCore
20+
1.0.1 K.Hoang 27/08/2022 Fix TCB0 disable bug
2021
*****************************************************************************************************************************/
2122

2223
#pragma once

0 commit comments

Comments
 (0)