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

Commit

Permalink
v1.0.1 for bug related to TCB0
Browse files Browse the repository at this point in the history
### 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`
  • Loading branch information
khoih-prog authored Aug 27, 2022
1 parent 24273fb commit e844b26
Show file tree
Hide file tree
Showing 24 changed files with 60 additions and 47 deletions.
6 changes: 6 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,19 @@
## Table of Contents

* [Changelog](#changelog)
* [Release v1.0.1](#release-v101)
* [Initial Release v1.0.0](#initial-release-v100)

---
---

## Changelog

### 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`

### Initial Release v1.0.0

1. Intial release to support Arduino **AVR ATtiny-based boards (ATtiny3217, etc.) using megaTinyCore**
Expand Down
4 changes: 2 additions & 2 deletions examples/Argument_Complex/Argument_Complex.ino
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@
#define USING_250KHZ false // Not supported now

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

#if USE_TIMER_0
#define CurrentTimer ITimer0
Expand Down
4 changes: 2 additions & 2 deletions examples/Argument_None/Argument_None.ino
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@
#define USING_250KHZ false // Not supported now

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

#if USE_TIMER_0
#define CurrentTimer ITimer0
Expand Down
4 changes: 2 additions & 2 deletions examples/Argument_Simple/Argument_Simple.ino
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@
#define USING_250KHZ false // Not supported now

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

#if USE_TIMER_0
#define CurrentTimer ITimer0
Expand Down
4 changes: 2 additions & 2 deletions examples/Change_Interval/Change_Interval.ino
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@
#define USING_250KHZ false // Not supported now

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

#if USE_TIMER_0
#define CurrentTimer ITimer0
Expand Down
4 changes: 2 additions & 2 deletions examples/Change_Interval_HF/Change_Interval_HF.ino
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@
#define USING_250KHZ false // Not supported now

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

#if USE_TIMER_0
#define CurrentTimer ITimer0
Expand Down
4 changes: 2 additions & 2 deletions examples/FakeAnalogWrite/FakeAnalogWrite.ino
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@
#define USING_250KHZ false // Not supported now

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

#if USE_TIMER_0
#define CurrentTimer ITimer0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,13 @@
// Select USING_HALF_CLOCK == true for 10/ 8MHz to Timer TCBx => shorter timer, but better accuracy
// Select USING_250KHZ == true for 250KHz to Timer TCBx => longer timer, but worse accuracy
// Not select for default 250KHz to Timer TCBx => longer timer, but worse accuracy
#define USING_FULL_CLOCK false
#define USING_HALF_CLOCK true
#define USING_FULL_CLOCK true
#define USING_HALF_CLOCK false
#define USING_250KHZ false // Not supported now

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

#if USE_TIMER_0
#define CurrentTimer ITimer0
Expand Down
4 changes: 2 additions & 2 deletions examples/ISR_RPM_Measure/ISR_RPM_Measure.ino
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@
#define USING_250KHZ false // Not supported now

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

#if USE_TIMER_0
#define CurrentTimer ITimer0
Expand Down
4 changes: 2 additions & 2 deletions examples/ISR_Timers_Array_Simple/ISR_Timers_Array_Simple.ino
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@
#define USING_250KHZ false // Not supported now

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

#if USE_TIMER_0
#define CurrentTimer ITimer0
Expand Down
4 changes: 2 additions & 2 deletions examples/RPM_Measure/RPM_Measure.ino
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@
#define USING_250KHZ false // Not supported now

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

#if USE_TIMER_0
#define CurrentTimer ITimer0
Expand Down
4 changes: 2 additions & 2 deletions examples/SwitchDebounce/SwitchDebounce.ino
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@
#define USING_250KHZ false // Not supported now

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

#if USE_TIMER_0
#define CurrentTimer ITimer0
Expand Down
4 changes: 2 additions & 2 deletions examples/TimerDuration/TimerDuration.ino
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@
#define USING_250KHZ false // Not supported now

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

#if USE_TIMER_0
#define CurrentTimer ITimer0
Expand Down
4 changes: 2 additions & 2 deletions examples/TimerInterruptTest/TimerInterruptTest.ino
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@
#define USING_250KHZ false // Not supported now

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

#if USE_TIMER_0
#define CurrentTimer ITimer0
Expand Down
4 changes: 2 additions & 2 deletions examples/multiFileProject/multiFileProject.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@
#define USING_250KHZ false // Not supported now

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

#if USE_TIMER_0
#define CurrentTimer ITimer0
Expand Down
2 changes: 1 addition & 1 deletion library.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ATtiny_TimerInterrupt",
"version": "1.0.0",
"version": "1.0.1",
"keywords": "timer, interrupt, isr, isr-based, timing, control, hardware-timer, mission-critical, accuracy, megaavr, avr-attiny, attiny, megatinycore, megatiny-core, attiny-timerinterrupt, tcb-timers",
"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",
"authors":
Expand Down
2 changes: 1 addition & 1 deletion library.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name=ATtiny_TimerInterrupt
version=1.0.0
version=1.0.1
author=Khoi Hoang
maintainer=Khoi Hoang <[email protected]>
sentence=This library enables you to use Interrupt from Hardware Timers on Arduino AVR ATtiny-based boards (ATtiny3217, etc.) using megaTinyCore
Expand Down
3 changes: 2 additions & 1 deletion src/ATtiny_ISR_Timer.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,12 @@
Therefore, their executions are not blocked by bad-behaving functions / tasks.
This important feature is absolutely necessary for mission-critical tasks.
Version: 1.0.0
Version: 1.0.1
Version Modified By Date Comments
------- ----------- ---------- -----------
1.0.0 K.Hoang 27/08/2022 Initial coding to support AVR ATtiny (ATtiny3217, etc.) using megaTinyCore
1.0.1 K.Hoang 27/08/2022 Fix TCB0 disable bug
*****************************************************************************************************************************/

#pragma once
Expand Down
9 changes: 5 additions & 4 deletions src/ATtiny_ISR_Timer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,12 @@
Therefore, their executions are not blocked by bad-behaving functions / tasks.
This important feature is absolutely necessary for mission-critical tasks.
Version: 1.0.0
Version: 1.0.1
Version Modified By Date Comments
------- ----------- ---------- -----------
1.0.0 K.Hoang 27/08/2022 Initial coding to support AVR ATtiny (ATtiny3217, etc.) using megaTinyCore
1.0.1 K.Hoang 27/08/2022 Fix TCB0 disable bug
*****************************************************************************************************************************/

#pragma once
Expand All @@ -31,13 +32,13 @@
#endif

#ifndef AT_TINY_TIMER_INTERRUPT_VERSION
#define AT_TINY_TIMER_INTERRUPT_VERSION F("ATtiny_TimerInterrupt v1.0.0")
#define AT_TINY_TIMER_INTERRUPT_VERSION F("ATtiny_TimerInterrupt v1.0.1")

#define AT_TINY_TIMER_INTERRUPT_VERSION_MAJOR 1
#define AT_TINY_TIMER_INTERRUPT_VERSION_MINOR 0
#define AT_TINY_TIMER_INTERRUPT_VERSION_PATCH 0
#define AT_TINY_TIMER_INTERRUPT_VERSION_PATCH 1

#define AT_TINY_TIMER_INTERRUPT_VERSION_INT 1000000
#define AT_TINY_TIMER_INTERRUPT_VERSION_INT 1000001
#endif

#include "TimerInterrupt_Generic_Debug.h"
Expand Down
3 changes: 2 additions & 1 deletion src/ATtiny_ISR_Timer_Impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,12 @@
Therefore, their executions are not blocked by bad-behaving functions / tasks.
This important feature is absolutely necessary for mission-critical tasks.
Version: 1.0.0
Version: 1.0.1
Version Modified By Date Comments
------- ----------- ---------- -----------
1.0.0 K.Hoang 27/08/2022 Initial coding to support AVR ATtiny (ATtiny3217, etc.) using megaTinyCore
1.0.1 K.Hoang 27/08/2022 Fix TCB0 disable bug
*****************************************************************************************************************************/

#pragma once
Expand Down
3 changes: 2 additions & 1 deletion src/ATtiny_TimerInterrupt.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,12 @@
Therefore, their executions are not blocked by bad-behaving functions / tasks.
This important feature is absolutely necessary for mission-critical tasks.
Version: 1.0.0
Version: 1.0.1
Version Modified By Date Comments
------- ----------- ---------- -----------
1.0.0 K.Hoang 27/08/2022 Initial coding to support AVR ATtiny (ATtiny3217, etc.) using megaTinyCore
1.0.1 K.Hoang 27/08/2022 Fix TCB0 disable bug
****************************************************************************************************************************/

#pragma once
Expand Down
9 changes: 5 additions & 4 deletions src/ATtiny_TimerInterrupt.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,12 @@
Therefore, their executions are not blocked by bad-behaving functions / tasks.
This important feature is absolutely necessary for mission-critical tasks.
Version: 1.0.0
Version: 1.0.1
Version Modified By Date Comments
------- ----------- ---------- -----------
1.0.0 K.Hoang 27/08/2022 Initial coding to support AVR ATtiny (ATtiny3217, etc.) using megaTinyCore
1.0.1 K.Hoang 27/08/2022 Fix TCB0 disable bug
****************************************************************************************************************************/

#pragma once
Expand Down Expand Up @@ -155,13 +156,13 @@
#include "TimerInterrupt_Generic_Debug.h"

#ifndef AT_TINY_TIMER_INTERRUPT_VERSION
#define AT_TINY_TIMER_INTERRUPT_VERSION F("ATtiny_TimerInterrupt v1.0.0")
#define AT_TINY_TIMER_INTERRUPT_VERSION F("ATtiny_TimerInterrupt v1.0.1")

#define AT_TINY_TIMER_INTERRUPT_VERSION_MAJOR 1
#define AT_TINY_TIMER_INTERRUPT_VERSION_MINOR 0
#define AT_TINY_TIMER_INTERRUPT_VERSION_PATCH 0
#define AT_TINY_TIMER_INTERRUPT_VERSION_PATCH 1

#define AT_TINY_TIMER_INTERRUPT_VERSION_INT 1000000
#define AT_TINY_TIMER_INTERRUPT_VERSION_INT 1000001
#endif

#include <avr/interrupt.h>
Expand Down
7 changes: 4 additions & 3 deletions src/ATtiny_TimerInterrupt_Impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,12 @@
Therefore, their executions are not blocked by bad-behaving functions / tasks.
This important feature is absolutely necessary for mission-critical tasks.
Version: 1.0.0
Version: 1.0.1
Version Modified By Date Comments
------- ----------- ---------- -----------
1.0.0 K.Hoang 27/08/2022 Initial coding to support AVR ATtiny (ATtiny3217, etc.) using megaTinyCore
1.0.1 K.Hoang 27/08/2022 Fix TCB0 disable bug
****************************************************************************************************************************/

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

// Limit frequency to larger than (0.00372529 / 64) Hz or interval 17179.840s / 17179840 ms to avoid uint32_t overflow
if ((_timer <= 0) || (callback == NULL) || ((frequencyLimit) < 1) )
{
if ((_timer < 0) || (callback == NULL) || ((frequencyLimit) < 1) )
{
return false;
}
else
Expand Down
3 changes: 2 additions & 1 deletion src/TimerInterrupt_Generic_Debug.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,12 @@
Therefore, their executions are not blocked by bad-behaving functions / tasks.
This important feature is absolutely necessary for mission-critical tasks.
Version: 1.0.0
Version: 1.0.1
Version Modified By Date Comments
------- ----------- ---------- -----------
1.0.0 K.Hoang 27/08/2022 Initial coding to support AVR ATtiny (ATtiny3217, etc.) using megaTinyCore
1.0.1 K.Hoang 27/08/2022 Fix TCB0 disable bug
*****************************************************************************************************************************/

#pragma once
Expand Down

0 comments on commit e844b26

Please sign in to comment.