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

Commit c593e91

Browse files
authored
v1.8.0 fixes doubling time bug
### Releases v1.8.0 1. Fix doubled time for `ESP32_C3`. Check [Error in the value defined by TIMER0_INTERVAL_MS #28](https://github.com/khoih-prog/ESP32_C3_TimerInterrupt/issues/28) 2. Modify examples to avoid using `LED_BUILTIN` / `GPIO2`, `GPIO1` as it can cause crash in some boards, such as `ESP32_C3` 3. Use `allman astyle` and add `utils`
1 parent ea8de75 commit c593e91

19 files changed

+913
-733
lines changed

CONTRIBUTING.md

+27-5
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ If you don't find anything, please [open a new issue](https://github.com/khoih-p
1515
Please ensure to specify the following:
1616

1717
* Arduino IDE version (e.g. 1.8.19) or Platform.io version
18-
* `ESP32` Core Version (e.g. ESP32 core v2.0.4)
18+
* `ESP32` Core Version (e.g. ESP32 core v2.0.5)
1919
* `ESP32-C3` Board type (e.g. ESP32C3_DEV Module, LOLIN_C3_MINI, DFROBOT_BEETLE_ESP32_C3, ADAFRUIT_QTPY_ESP32C3, AirM2M_CORE_ESP32C3, XIAO_ESP32C3, etc.)
2020
* Contextual information (e.g. what you were trying to achieve)
2121
* Simplest possible steps to reproduce
@@ -28,28 +28,50 @@ Please ensure to specify the following:
2828

2929
```
3030
Arduino IDE version: 1.8.19
31-
ESP32 Core Version v2.0.4
31+
ESP32 core v2.0.5
3232
ESP32C3_DEV Module
3333
OS: Ubuntu 20.04 LTS
34-
Linux xy-Inspiron-3593 5.15.0-41-generic #44~20.04.1-Ubuntu SMP Fri Jun 24 13:27:29 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux
34+
Linux xy-Inspiron-3593 5.15.0-52-generic #58~20.04.1-Ubuntu SMP Thu Oct 13 13:09:46 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux
3535
3636
Context:
37-
I encountered a crash while using TimerInterrupt.
38-
37+
I encountered a crash while using this library
3938
Steps to reproduce:
4039
1. ...
4140
2. ...
4241
3. ...
4342
4. ...
4443
```
4544

45+
### Additional context
46+
47+
Add any other context about the problem here.
48+
49+
---
50+
4651
### Sending Feature Requests
4752

4853
Feel free to post feature requests. It's helpful if you can explain exactly why the feature would be useful.
4954

5055
There are usually some outstanding feature requests in the [existing issues list](https://github.com/khoih-prog/ESP32_C3_TimerInterrupt/issues?q=is%3Aopen+is%3Aissue+label%3Aenhancement), feel free to add comments to them.
5156

57+
---
58+
5259
### Sending Pull Requests
5360

5461
Pull Requests with changes and fixes are also welcome!
5562

63+
Please use the `astyle` to reformat the updated library code as follows (demo for Ubuntu Linux)
64+
65+
1. Change directory to the library GitHub
66+
67+
```
68+
xy@xy-Inspiron-3593:~$ cd Arduino/xy/ESP32_C3_TimerInterrupt_GitHub/
69+
xy@xy-Inspiron-3593:~/Arduino/xy/ESP32_C3_TimerInterrupt_GitHub$
70+
```
71+
72+
2. Issue astyle command
73+
74+
```
75+
xy@xy-Inspiron-3593:~/Arduino/xy/ESP32_C3_TimerInterrupt_GitHub$ bash utils/restyle.sh
76+
```
77+

changelog.md

+13-2
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,22 @@
22

33
[![arduino-library-badge](https://www.ardu-badge.com/badge/ESP32_C3_TimerInterrupt.svg?)](https://www.ardu-badge.com/ESP32_C3_TimerInterrupt)
44
[![GitHub release](https://img.shields.io/github/release/khoih-prog/ESP32_C3_TimerInterrupt.svg)](https://github.com/khoih-prog/ESP32_C3_TimerInterrupt/releases)
5-
[![GitHub](https://img.shields.io/github/license/mashape/apistatus.svg)](https://github.com/khoih-prog/ESP32_C3_TimerInterrupt/blob/master/LICENSE)
5+
[![GitHub](https://img.shields.io/github/license/mashape/apistatus.svg)](https://github.com/khoih-prog/ESP32_C3_TimerInterrupt/blob/main/LICENSE)
66
[![contributions welcome](https://img.shields.io/badge/contributions-welcome-brightgreen.svg?style=flat)](#Contributing)
77
[![GitHub issues](https://img.shields.io/github/issues/khoih-prog/ESP32_C3_TimerInterrupt.svg)](http://github.com/khoih-prog/ESP32_C3_TimerInterrupt/issues)
88

9+
<a href="https://www.buymeacoffee.com/khoihprog6" title="Donate to my libraries using BuyMeACoffee"><img src="https://cdn.buymeacoffee.com/buttons/v2/default-yellow.png" alt="Donate to my libraries using BuyMeACoffee" style="height: 50px !important;width: 181px !important;" ></a>
10+
<a href="https://www.buymeacoffee.com/khoihprog6" title="Donate to my libraries using BuyMeACoffee"><img src="https://img.shields.io/badge/buy%20me%20a%20coffee-donate-orange.svg?logo=buy-me-a-coffee&logoColor=FFDD00" style="height: 20px !important;width: 200px !important;" ></a>
11+
<a href="https://profile-counter.glitch.me/khoih-prog/count.svg" title="Total khoih-prog Visitor count"><img src="https://profile-counter.glitch.me/khoih-prog/count.svg" style="height: 30px;width: 200px;"></a>
12+
<a href="https://profile-counter.glitch.me/khoih-prog-ESP32_C3_TimerInterrupt/count.svg" title="ESP32_C3_TimerInterrupt Visitor count"><img src="https://profile-counter.glitch.me/khoih-prog-ESP32_C3_TimerInterrupt/count.svg" style="height: 30px;width: 200px;"></a>
913

1014
---
1115
---
1216

1317
## Table of Contents
1418

1519
* [Changelog](#changelog)
20+
* [Releases v1.8.0](#releases-v180)
1621
* [Releases v1.7.0](#releases-v170)
1722
* [Releases v1.6.0](#releases-v160)
1823
* [Releases v1.5.0](#releases-v150)
@@ -23,11 +28,17 @@
2328

2429
## Changelog
2530

31+
### Releases v1.8.0
32+
33+
1. Fix doubled time for `ESP32_C3`. Check [Error in the value defined by TIMER0_INTERVAL_MS #28](https://github.com/khoih-prog/ESP32_C3_TimerInterrupt/issues/28)
34+
2. Modify examples to avoid using `LED_BUILTIN` / `GPIO2`, `GPIO1` as it can cause crash in some boards, such as `ESP32_C3`
35+
3. Use `allman astyle` and add `utils`
36+
2637
### Releases v1.7.0
2738

2839
1. Add support to
2940
- ESP32_C3 : LOLIN_C3_MINI, DFROBOT_BEETLE_ESP32_C3, ADAFRUIT_QTPY_ESP32C3, AirM2M_CORE_ESP32C3, XIAO_ESP32C3
30-
41+
3142
### Releases v1.6.0
3243

3344
1. Suppress errors and warnings for new ESP32 core v2.0.4+

examples/Argument_None/Argument_None.ino

+58-53
Original file line numberDiff line numberDiff line change
@@ -46,35 +46,34 @@
4646
// Can be included as many times as necessary, without `Multiple Definitions` Linker Error
4747
#include "ESP32_C3_TimerInterrupt.h"
4848

49-
#ifndef LED_BUILTIN
50-
#define LED_BUILTIN 2 // Pin D2 mapped to pin GPIO2/ADC12 of ESP32, control on-board LED
51-
#endif
52-
53-
#define PIN_D1 1 // Pin D1 mapped to pin GPIO1 of ESP32-S2
49+
// Don't use PIN_D3 in core v2.0.0 and v2.0.1. Check https://github.com/espressif/arduino-esp32/issues/5868
50+
// Don't use PIN_D2 with ESP32_C3 (crash)
51+
#define PIN_D39 19 // Pin D19 mapped to pin GPIO9 of ESP32
52+
#define PIN_D3 3 // Pin D3 mapped to pin GPIO3/RX0 of ESP32
5453

5554
bool IRAM_ATTR TimerHandler0(void * timerNo)
56-
{
57-
static bool toggle0 = false;
58-
59-
//timer interrupt toggles pin LED_BUILTIN
60-
digitalWrite(LED_BUILTIN, toggle0);
61-
toggle0 = !toggle0;
62-
63-
return true;
55+
{
56+
static bool toggle0 = false;
57+
58+
//timer interrupt toggles pin PIN_D39
59+
digitalWrite(PIN_D39, toggle0);
60+
toggle0 = !toggle0;
61+
62+
return true;
6463
}
6564

6665
bool IRAM_ATTR TimerHandler1(void * timerNo)
6766
{
68-
static bool toggle1 = false;
67+
static bool toggle1 = false;
6968

70-
//timer interrupt toggles outputPin
71-
digitalWrite(PIN_D1, toggle1);
72-
toggle1 = !toggle1;
69+
//timer interrupt toggles outputPin
70+
digitalWrite(PIN_D3, toggle1);
71+
toggle1 = !toggle1;
7372

74-
return true;
73+
return true;
7574
}
7675

77-
#define TIMER0_INTERVAL_MS 1000
76+
#define TIMER0_INTERVAL_MS 100 //1000
7877

7978
#define TIMER1_INTERVAL_MS 5000
8079

@@ -84,40 +83,46 @@ ESP32Timer ITimer1(1);
8483

8584
void setup()
8685
{
87-
pinMode(LED_BUILTIN, OUTPUT);
88-
pinMode(PIN_D1, OUTPUT);
89-
90-
Serial.begin(115200);
91-
while (!Serial);
92-
93-
delay(100);
94-
95-
Serial.print(F("\nStarting Argument_None on ")); Serial.println(ARDUINO_BOARD);
96-
Serial.println(ESP32_C3_TIMER_INTERRUPT_VERSION);
97-
Serial.print(F("CPU Frequency = ")); Serial.print(F_CPU / 1000000); Serial.println(F(" MHz"));
98-
99-
// Using ESP32 => 80 / 160 / 240MHz CPU clock ,
100-
// For 64-bit timer counter
101-
// For 16-bit timer prescaler up to 1024
102-
103-
// Interval in microsecs
104-
if (ITimer0.attachInterruptInterval(TIMER0_INTERVAL_MS * 1000, TimerHandler0))
105-
//if (ITimer0.attachInterrupt(1, TimerHandler0))
106-
{
107-
Serial.print(F("Starting ITimer0 OK, millis() = ")); Serial.println(millis());
108-
}
109-
else
110-
Serial.println(F("Can't set ITimer0. Select another Timer, freq. or timer"));
111-
112-
113-
// Interval in microsecs
114-
if (ITimer1.attachInterruptInterval(TIMER1_INTERVAL_MS * 1000, TimerHandler1))
115-
//if (ITimer1.attachInterrupt(2, TimerHandler1))
116-
{
117-
Serial.print(F("Starting ITimer1 OK, millis() = ")); Serial.println(millis());
118-
}
119-
else
120-
Serial.println(F("Can't set ITimer1. Select another Timer, freq. or timer"));
86+
pinMode(PIN_D39, OUTPUT);
87+
pinMode(PIN_D3, OUTPUT);
88+
89+
Serial.begin(115200);
90+
91+
while (!Serial && millis() < 5000);
92+
93+
delay(500);
94+
95+
Serial.print(F("\nStarting Argument_None on "));
96+
Serial.println(ARDUINO_BOARD);
97+
Serial.println(ESP32_C3_TIMER_INTERRUPT_VERSION);
98+
Serial.print(F("CPU Frequency = "));
99+
Serial.print(F_CPU / 1000000);
100+
Serial.println(F(" MHz"));
101+
102+
// Using ESP32 => 80 / 160 / 240MHz CPU clock ,
103+
// For 64-bit timer counter
104+
// For 16-bit timer prescaler up to 1024
105+
106+
// Interval in microsecs
107+
if (ITimer0.attachInterruptInterval(TIMER0_INTERVAL_MS * 1000, TimerHandler0))
108+
//if (ITimer0.attachInterrupt(1, TimerHandler0))
109+
{
110+
Serial.print(F("Starting ITimer0 OK, millis() = "));
111+
Serial.println(millis());
112+
}
113+
else
114+
Serial.println(F("Can't set ITimer0. Select another Timer, freq. or timer"));
115+
116+
117+
// Interval in microsecs
118+
if (ITimer1.attachInterruptInterval(TIMER1_INTERVAL_MS * 1000, TimerHandler1))
119+
//if (ITimer1.attachInterrupt(2, TimerHandler1))
120+
{
121+
Serial.print(F("Starting ITimer1 OK, millis() = "));
122+
Serial.println(millis());
123+
}
124+
else
125+
Serial.println(F("Can't set ITimer1. Select another Timer, freq. or timer"));
121126
}
122127

123128
void loop()

0 commit comments

Comments
 (0)