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

Commit

Permalink
v1.8.0 fixes doubling time bug
Browse files Browse the repository at this point in the history
### Releases v1.8.0

1. Fix doubled time for `ESP32_S2`. 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`
  • Loading branch information
khoih-prog authored Nov 16, 2022
1 parent 08fb361 commit eb0da82
Show file tree
Hide file tree
Showing 19 changed files with 1,050 additions and 753 deletions.
35 changes: 29 additions & 6 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ If you don't find anything, please [open a new issue](https://github.com/khoih-p
Please ensure to specify the following:

* Arduino IDE version (e.g. 1.8.19) or Platform.io version
* `ESP32` Core Version (e.g. ESP32 core v2.0.4)
* `ESP32` Core Version (e.g. ESP32 core v2.0.5)
* `ESP32-S2` Board type (e.g. ESP32S2_DEV Module, ESP32_S2_Saola, etc.)
* Contextual information (e.g. what you were trying to achieve)
* Simplest possible steps to reproduce
Expand All @@ -28,28 +28,51 @@ Please ensure to specify the following:

```
Arduino IDE version: 1.8.19
ESP32 core v2.0.4
ESP32S2_DEV Module
ESP32 core v2.0.5
ESP32S3_DEV Module
OS: Ubuntu 20.04 LTS
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
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
Context:
I encountered a crash while using TimerInterrupt.
I encountered a crash while using this library
Steps to reproduce:
1. ...
2. ...
3. ...
4. ...
```

### Additional context

Add any other context about the problem here.

---

### Sending Feature Requests

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

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

---

### Sending Pull Requests

Pull Requests with changes and fixes are also welcome!

Please use the `astyle` to reformat the updated library code as follows (demo for Ubuntu Linux)

1. Change directory to the library GitHub

```
xy@xy-Inspiron-3593:~$ cd Arduino/xy/ESP32_S2_TimerInterrupt_GitHub/
xy@xy-Inspiron-3593:~/Arduino/xy/ESP32_S2_TimerInterrupt_GitHub$
```

2. Issue astyle command

```
xy@xy-Inspiron-3593:~/Arduino/xy/ESP32_S2_TimerInterrupt_GitHub$ bash utils/restyle.sh
```


17 changes: 15 additions & 2 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,23 @@

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


<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>
<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>
<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>
<a href="https://profile-counter.glitch.me/khoih-prog-ESP32_S2_TimerInterrupt/count.svg" title="ESP32_S2_TimerInterrupt Visitor count"><img src="https://profile-counter.glitch.me/khoih-prog-ESP32_S2_TimerInterrupt/count.svg" style="height: 30px;width: 200px;"></a>

---
---

## Table of Contents

* [Changelog](#changelog)
* [Releases v1.8.0](#releases-v180)
* [Releases v1.7.0](#releases-v170)
* [Releases v1.6.0](#releases-v160)
* [Releases v1.5.1](#releases-v151)
Expand All @@ -24,6 +31,12 @@

## Changelog

### Releases v1.8.0

1. Fix doubled time for `ESP32_S2`. 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`

### Releases v1.7.0

1. Add support to
Expand Down Expand Up @@ -56,5 +69,5 @@
### Releases v1.3.0

1. Initial coding to support ESP32-S2
2. Sync with [ESP32TimerInterrupt library v1.3.0](https://github.com/khoih-prog/ESP32TimerInterrupt)
2. Sync with [ESP32_S2_TimerInterrupt library v1.3.0](https://github.com/khoih-prog/ESP32_S2_TimerInterrupt)

110 changes: 57 additions & 53 deletions examples/Argument_None/Argument_None.ino
Original file line number Diff line number Diff line change
Expand Up @@ -38,36 +38,34 @@

#include "ESP32_S2_TimerInterrupt.h"

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

#define PIN_D1 1 // Pin D1 mapped to pin GPIO1 of ESP32-S2
bool IRAM_ATTR TimerHandler0(void * timerNo)
{
static bool toggle0 = false;

//timer interrupt toggles pin PIN_D19
digitalWrite(PIN_D19, toggle0);
toggle0 = !toggle0;

bool IRAM_ATTR TimerHandler0(void * timerNo)
{
static bool toggle0 = false;

//timer interrupt toggles pin LED_BUILTIN
digitalWrite(LED_BUILTIN, toggle0);
toggle0 = !toggle0;

return true;
return true;
}

bool IRAM_ATTR TimerHandler1(void * timerNo)
{
static bool toggle1 = false;
static bool toggle1 = false;

//timer interrupt toggles outputPin
digitalWrite(PIN_D1, toggle1);
toggle1 = !toggle1;
//timer interrupt toggles outputPin
digitalWrite(PIN_D3, toggle1);
toggle1 = !toggle1;

return true;
return true;
}

#define TIMER0_INTERVAL_MS 1000
#define TIMER0_INTERVAL_MS 100

#define TIMER1_INTERVAL_MS 5000

Expand All @@ -77,40 +75,46 @@ ESP32Timer ITimer1(1);

void setup()
{
pinMode(LED_BUILTIN, OUTPUT);
pinMode(PIN_D1, OUTPUT);

Serial.begin(115200);
while (!Serial);

delay(100);

Serial.print(F("\nStarting Argument_None on ")); Serial.println(ARDUINO_BOARD);
Serial.println(ESP32_S2_TIMER_INTERRUPT_VERSION);
Serial.print(F("CPU Frequency = ")); Serial.print(F_CPU / 1000000); Serial.println(F(" MHz"));

// Using ESP32 => 80 / 160 / 240MHz CPU clock ,
// For 64-bit timer counter
// For 16-bit timer prescaler up to 1024

// Interval in microsecs
if (ITimer0.attachInterruptInterval(TIMER0_INTERVAL_MS * 1000, TimerHandler0))
//if (ITimer0.attachInterrupt(1, TimerHandler0))
{
Serial.print(F("Starting ITimer0 OK, millis() = ")); Serial.println(millis());
}
else
Serial.println(F("Can't set ITimer0. Select another Timer, freq. or timer"));


// Interval in microsecs
if (ITimer1.attachInterruptInterval(TIMER1_INTERVAL_MS * 1000, TimerHandler1))
//if (ITimer1.attachInterrupt(2, TimerHandler1))
{
Serial.print(F("Starting ITimer1 OK, millis() = ")); Serial.println(millis());
}
else
Serial.println(F("Can't set ITimer1. Select another Timer, freq. or timer"));
pinMode(PIN_D19, OUTPUT);
pinMode(PIN_D3, OUTPUT);

Serial.begin(115200);

while (!Serial && millis() < 5000);

delay(500);

Serial.print(F("\nStarting Argument_None on "));
Serial.println(ARDUINO_BOARD);
Serial.println(ESP32_S2_TIMER_INTERRUPT_VERSION);
Serial.print(F("CPU Frequency = "));
Serial.print(F_CPU / 1000000);
Serial.println(F(" MHz"));

// Using ESP32 => 80 / 160 / 240MHz CPU clock ,
// For 64-bit timer counter
// For 16-bit timer prescaler up to 1024

// Interval in microsecs
if (ITimer0.attachInterruptInterval(TIMER0_INTERVAL_MS * 1000, TimerHandler0))
//if (ITimer0.attachInterrupt(1, TimerHandler0))
{
Serial.print(F("Starting ITimer0 OK, millis() = "));
Serial.println(millis());
}
else
Serial.println(F("Can't set ITimer0. Select another Timer, freq. or timer"));


// Interval in microsecs
if (ITimer1.attachInterruptInterval(TIMER1_INTERVAL_MS * 1000, TimerHandler1))
//if (ITimer1.attachInterrupt(2, TimerHandler1))
{
Serial.print(F("Starting ITimer1 OK, millis() = "));
Serial.println(millis());
}
else
Serial.println(F("Can't set ITimer1. Select another Timer, freq. or timer"));
}

void loop()
Expand Down
Loading

0 comments on commit eb0da82

Please sign in to comment.