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

Commit 9643d66

Browse files
authored
v1.1.1 for core v2.0.1+
### Releases v1.1.1 1. Fix examples to not use GPIO1/TX0 for core v2.0.1+
1 parent 6d67f0e commit 9643d66

20 files changed

+67
-52
lines changed

CONTRIBUTING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ Arduino IDE version: 1.8.16
3131
ESP32 core v2.0.0
3232
ESP32S2_DEV Module
3333
OS: Ubuntu 20.04 LTS
34-
Linux xy-Inspiron-3593 5.4.0-86-generic #97-Ubuntu SMP Fri Sep 17 19:19:40 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux
34+
Linux xy-Inspiron-3593 5.4.0-90-generic #101-Ubuntu SMP Fri Oct 15 20:00:55 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux
3535
3636
Context:
3737
I encountered a crash while using TimerInterrupt.

README.md

Lines changed: 13 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@
1212
## Table of Contents
1313

1414
* [Why do we need this ESP32_PWM library](#why-do-we-need-this-ESP32_PWM-library)
15-
* [Important notes](#Important-notes)
16-
* [Features](#features)
1715
* [Why using ISR-based PWM-channels is better](#Why-using-ISR-based-PWM-channels-is-better)
1816
* [Currently supported Boards](#currently-supported-boards)
1917
* [Important Notes about ISR](#important-notes-about-isr)
@@ -60,15 +58,6 @@
6058

6159
### Why do we need this [ESP32_PWM library](https://github.com/khoih-prog/ESP32_PWM)
6260

63-
### Important notes
64-
65-
**Don't use ESP32 Core v2.0.1 RC1 yet** as it introduces new breaking features compared to v2.0.0 and will crash these examples
66-
67-
* [ 1. ISR_16_PWMs_Array](examples/ISR_16_PWMs_Array)
68-
* [ 2. ISR_16_PWMs_Array_Complex](examples/ISR_16_PWMs_Array_Complex)
69-
* [ 3. ISR_16_PWMs_Array_Simple](examples/ISR_16_PWMs_Array_Simple)
70-
71-
7261
### Features
7362

7463
This library enables you to use Interrupt from Hardware Timers on an ESP32, ESP32_S2-based board to create and output PWM to pins. Becayse this library doesn't use the powerful hardware-controlled PWM with limitations, the maximum PWM frequency is currently limited at **500Hz**, which is suitable for many real-life applications. Now you can also modify PWM settings on-the-fly.
@@ -131,7 +120,8 @@ The catch is **your function is now part of an ISR (Interrupt Service Routine),
131120
## Prerequisites
132121

133122
1. [`Arduino IDE 1.8.16+` for Arduino](https://www.arduino.cc/en/Main/Software)
134-
2. [`ESP32 Core 2.0.0+`](https://github.com/espressif/arduino-esp32) for ESP32-based boards. [![Latest release](https://img.shields.io/github/release/espressif/arduino-esp32.svg)](https://github.com/espressif/arduino-esp32/releases/latest/). **Don't use ESP32 core v2.0.1-RC1**. Check [Important notes](#Important-notes)
123+
2. [`ESP32 Core 2.0.1+`](https://github.com/espressif/arduino-esp32) for ESP32-based boards. [![Latest release](https://img.shields.io/github/release/espressif/arduino-esp32.svg)](https://github.com/espressif/arduino-esp32/releases/latest/).
124+
135125
---
136126
---
137127

@@ -398,10 +388,11 @@ volatile unsigned long deltaMicrosStop [NUMBER_ISR_PWMS] = { 0, 0, 0, 0, 0,
398388
volatile unsigned long previousMicrosStop [NUMBER_ISR_PWMS] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
399389
400390
// You can assign pins here. Be carefull to select good pin to use or crash, e.g pin 6-11
391+
// Can't use PIN_D1 for core v2.0.1+
401392
uint32_t PWM_Pin[NUMBER_ISR_PWMS] =
402393
{
403-
PIN_D1, LED_BUILTIN, PIN_D3, PIN_D4, PIN_D5, PIN_D12, PIN_D13, PIN_D14,
404-
PIN_D15, PIN_D16, PIN_D17, PIN_D18, PIN_D19, PIN_D21, PIN_D22, PIN_D23
394+
PIN_D24, LED_BUILTIN, PIN_D3, PIN_D4, PIN_D5, PIN_D12, PIN_D13, PIN_D14,
395+
PIN_D15, PIN_D16, PIN_D17, PIN_D18, PIN_D19, PIN_D21, PIN_D22, PIN_D23
405396
};
406397
407398
// You can assign any interval for any timer here, in microseconds
@@ -855,7 +846,7 @@ The following is the sample terminal output when running example [ISR_16_PWMs_Ar
855846

856847
```
857848
Starting ISR_16_PWMs_Array_Complex on ESP32_DEV
858-
ESP32_PWM v1.1.0
849+
ESP32_PWM v1.1.1
859850
CPU Frequency = 240 MHz
860851
[PWM] ESP32_TimerInterrupt: _timerNo = 1 , _fre = 1000000
861852
[PWM] TIMER_BASE_CLK = 80000000 , TIMER_DIVIDER = 80
@@ -923,7 +914,7 @@ The following is the sample terminal output when running example [ISR_16_PWMs_Ar
923914

924915
```
925916
Starting ISR_16_PWMs_Array on ESP32_DEV
926-
ESP32_PWM v1.1.0
917+
ESP32_PWM v1.1.1
927918
CPU Frequency = 240 MHz
928919
[PWM] ESP32_TimerInterrupt: _timerNo = 1 , _fre = 1000000
929920
[PWM] TIMER_BASE_CLK = 80000000 , TIMER_DIVIDER = 80
@@ -958,7 +949,7 @@ The following is the sample terminal output when running example [ISR_16_PWMs_Ar
958949

959950
```
960951
Starting ISR_16_PWMs_Array_Simple on ESP32_DEV
961-
ESP32_PWM v1.1.0
952+
ESP32_PWM v1.1.1
962953
CPU Frequency = 240 MHz
963954
[PWM] ESP32_TimerInterrupt: _timerNo = 1 , _fre = 1000000
964955
[PWM] TIMER_BASE_CLK = 80000000 , TIMER_DIVIDER = 80
@@ -992,7 +983,7 @@ The following is the sample terminal output when running example [ISR_Modify_PWM
992983

993984
```
994985
Starting ISR_Modify_PWM on ESP32_DEV
995-
ESP32_PWM v1.1.0
986+
ESP32_PWM v1.1.1
996987
CPU Frequency = 240 MHz
997988
[PWM] ESP32_TimerInterrupt: _timerNo = 1 , _fre = 1000000
998989
[PWM] TIMER_BASE_CLK = 80000000 , TIMER_DIVIDER = 80
@@ -1018,7 +1009,7 @@ The following is the sample terminal output when running example [ISR_Changing_P
10181009

10191010
```
10201011
Starting ISR_Changing_PWM on ESP32_DEV
1021-
ESP32_PWM v1.1.0
1012+
ESP32_PWM v1.1.1
10221013
CPU Frequency = 240 MHz
10231014
[PWM] ESP32_TimerInterrupt: _timerNo = 1 , _fre = 1000000
10241015
[PWM] TIMER_BASE_CLK = 80000000 , TIMER_DIVIDER = 80
@@ -1044,7 +1035,7 @@ The following is the sample terminal output when running example [ISR_Modify_PWM
10441035

10451036
```
10461037
Starting ISR_Modify_PWM on ESP32S2_DEV
1047-
ESP32_PWM v1.1.0
1038+
ESP32_PWM v1.1.1
10481039
CPU Frequency = 240 MHz
10491040
[PWM] ESP32_S2_TimerInterrupt: _timerNo = 1 , _fre = 1000000
10501041
[PWM] TIMER_BASE_CLK = 80000000 , TIMER_DIVIDER = 80
@@ -1067,7 +1058,7 @@ The following is the sample terminal output when running example [ISR_Changing_P
10671058

10681059
```
10691060
Starting ISR_Changing_PWM on ESP32S2_DEV
1070-
ESP32_PWM v1.1.0
1061+
ESP32_PWM v1.1.1
10711062
CPU Frequency = 240 MHz
10721063
[PWM] ESP32_S2_TimerInterrupt: _timerNo = 1 , _fre = 1000000
10731064
[PWM] TIMER_BASE_CLK = 80000000 , TIMER_DIVIDER = 80
@@ -1134,6 +1125,7 @@ Submit issues to: [ESP32_PWM issues](https://github.com/khoih-prog/ESP32_PWM/iss
11341125
2. Longer time interval
11351126
3. Add complex examples.
11361127
4. Add functions to modify PWM settings on-the-fly
1128+
5. Fix examples to use with ESP32 core v2.0.1+
11371129

11381130
---
11391131
---

changelog.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
## Table of Contents
1313

1414
* [Changelog](#changelog)
15+
* [Releases v1.1.1](#releases-v111)
1516
* [Releases v1.1.0](#releases-v110)
1617
* [Releases v1.0.1](#releases-v101)
1718
* [Releases v1.0.0](#releases-v100)
@@ -21,6 +22,10 @@
2122

2223
## Changelog
2324

25+
### Releases v1.1.1
26+
27+
1. Fix examples to not use GPIO1/TX0 for core v2.0.1+
28+
2429
### Releases v1.1.0
2530

2631
1. Add functions to modify PWM settings on-the-fly

examples/ISR_16_PWMs_Array/ISR_16_PWMs_Array.ino

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,10 +98,11 @@ bool IRAM_ATTR TimerHandler(void * timerNo)
9898
//////////////////////////////////////////////////////
9999

100100
// You can assign pins here. Be carefull to select good pin to use or crash, e.g pin 6-11
101+
// Can't use PIN_D1 for core v2.0.1+
101102
uint32_t PWM_Pin[NUMBER_ISR_PWMS] =
102103
{
103-
PIN_D1, LED_BUILTIN, PIN_D3, PIN_D4, PIN_D5, PIN_D12, PIN_D13, PIN_D14,
104-
PIN_D15, PIN_D16, PIN_D17, PIN_D18, PIN_D19, PIN_D21, PIN_D22, PIN_D23
104+
PIN_D24, LED_BUILTIN, PIN_D3, PIN_D4, PIN_D5, PIN_D12, PIN_D13, PIN_D14,
105+
PIN_D15, PIN_D16, PIN_D17, PIN_D18, PIN_D19, PIN_D21, PIN_D22, PIN_D23
105106
};
106107

107108
// You can assign any interval for any timer here, in microseconds

examples/ISR_16_PWMs_Array_Complex/ISR_16_PWMs_Array_Complex.ino

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -145,10 +145,11 @@ volatile unsigned long deltaMicrosStop [NUMBER_ISR_PWMS] = { 0, 0, 0, 0, 0,
145145
volatile unsigned long previousMicrosStop [NUMBER_ISR_PWMS] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
146146

147147
// You can assign pins here. Be carefull to select good pin to use or crash, e.g pin 6-11
148+
// Can't use PIN_D1 for core v2.0.1+
148149
uint32_t PWM_Pin[NUMBER_ISR_PWMS] =
149150
{
150-
PIN_D1, LED_BUILTIN, PIN_D3, PIN_D4, PIN_D5, PIN_D12, PIN_D13, PIN_D14,
151-
PIN_D15, PIN_D16, PIN_D17, PIN_D18, PIN_D19, PIN_D21, PIN_D22, PIN_D23
151+
PIN_D24, LED_BUILTIN, PIN_D3, PIN_D4, PIN_D5, PIN_D12, PIN_D13, PIN_D14,
152+
PIN_D15, PIN_D16, PIN_D17, PIN_D18, PIN_D19, PIN_D21, PIN_D22, PIN_D23
152153
};
153154

154155
// You can assign any interval for any timer here, in microseconds

examples/ISR_16_PWMs_Array_Simple/ISR_16_PWMs_Array_Simple.ino

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,9 +100,10 @@ bool IRAM_ATTR TimerHandler(void * timerNo)
100100
//////////////////////////////////////////////////////
101101

102102
// You can assign pins here. Be carefull to select good pin to use or crash, e.g pin 6-11
103+
// Can't use PIN_D1 for core v2.0.1+
103104
uint32_t PWM_Pin[NUMBER_ISR_PWMS] =
104105
{
105-
PIN_D1, LED_BUILTIN, PIN_D3, PIN_D4, PIN_D5, PIN_D12, PIN_D13, PIN_D14,
106+
PIN_D24, LED_BUILTIN, PIN_D3, PIN_D4, PIN_D5, PIN_D12, PIN_D13, PIN_D14,
106107
PIN_D15, PIN_D16, PIN_D17, PIN_D18, PIN_D19, PIN_D21, PIN_D22, PIN_D23
107108
};
108109

@@ -154,6 +155,7 @@ void setup()
154155
// Just to demonstrate, don't use too many ISR Timers if not absolutely necessary
155156
// You can use up to 16 timer for each ISR_PWM
156157
for (uint16_t i = 0; i < NUMBER_ISR_PWMS; i++)
158+
//for (uint16_t i = 0; i < 1; i++)
157159
{
158160
//void setPWM(uint32_t pin, uint32_t frequency, uint32_t dutycycle
159161
// , timer_callback_p StartCallback = nullptr, timer_callback_p StopCallback = nullptr)

library.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "ESP32_PWM",
3-
"version": "1.1.0",
3+
"version": "1.1.1",
44
"keywords": "timing, device, control, pwm, timer, interrupt, hardware, isr, isr-based, hardware-timer, isr-timer, isr-based-timer, mission-critical, accuracy, precise, non-blocking, esp32, esp32-s2, esp32-c3, synchronized-PWM, on-the-fly",
55
"description": "This library enables you to use Interrupt from Hardware Timers on an ESP32, ESP32_S2 or ESP32_C3-based board to create and output PWM to pins. It now supports 16 ISR-based synchronized PWM channels, while consuming only 1 Hardware Timer. PWM interval can be very long (uint32_t millisecs). The most important feature is they're ISR-based PWM channels. Therefore, their executions are not blocked by bad-behaving functions or tasks. This important feature is absolutely necessary for mission-critical tasks. These hardware PWM channels, 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's necessary if you need to measure some data requiring better accuracy. Now you can change the PWM settings on-the-fly",
66
"authors":

library.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name=ESP32_PWM
2-
version=1.1.0
2+
version=1.1.1
33
author=Khoi Hoang <[email protected]>
44
maintainer=Khoi Hoang <[email protected]>
55
sentence=This library enables you to use Interrupt from Hardware Timers on an ESP32, ESP32_S2 or ESP32_C3-based board to create and output PWM to pins.

src/ESP32_PWM.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,14 @@
2121
Therefore, their executions are not blocked by bad-behaving functions / tasks.
2222
This important feature is absolutely necessary for mission-critical tasks.
2323
24-
Version: 1.1.0
24+
Version: 1.1.1
2525
2626
Version Modified By Date Comments
2727
------- ----------- ---------- -----------
2828
1.0.0 K Hoang 20/09/2021 Initial coding for ESP32, ESP32_S2, ESP32_C3 boards with ESP32 core v2.0.0+
2929
1.0.1 K Hoang 21/09/2021 Fix bug. Ading PWM end-of-duty-cycle callback function. Improve examples
3030
1.1.0 K Hoang 06/11/2021 Add functions to modify PWM settings on-the-fly
31+
1.1.1 K Hoang 09/11/2021 Fix examples to not use GPIO1/TX0 for core v2.0.1+
3132
*****************************************************************************************************************************/
3233

3334
#pragma once
@@ -54,7 +55,7 @@
5455
#endif
5556

5657
#ifndef ESP32_PWM_VERSION
57-
#define ESP32_PWM_VERSION "ESP32_PWM v1.1.0"
58+
#define ESP32_PWM_VERSION "ESP32_PWM v1.1.1"
5859
#endif
5960

6061
#ifndef TIMER_INTERRUPT_DEBUG

src/ESP32_PWM_ISR.h

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,14 @@
2020
Therefore, their executions are not blocked by bad-behaving functions / tasks.
2121
This important feature is absolutely necessary for mission-critical tasks.
2222
23-
Version: 1.1.0
23+
Version: 1.1.1
2424
2525
Version Modified By Date Comments
2626
------- ----------- ---------- -----------
2727
1.0.0 K Hoang 20/09/2021 Initial coding for ESP32, ESP32_S2, ESP32_C3 boards with ESP32 core v2.0.0+
2828
1.0.1 K Hoang 21/09/2021 Fix bug. Ading PWM end-of-duty-cycle callback function. Improve examples
2929
1.1.0 K Hoang 06/11/2021 Add functions to modify PWM settings on-the-fly
30+
1.1.1 K Hoang 09/11/2021 Fix examples to not use GPIO1/TX0 for core v2.0.1+
3031
*****************************************************************************************************************************/
3132

3233
#pragma once
@@ -41,7 +42,7 @@
4142
#endif
4243

4344
#ifndef ESP32_PWM_VERSION
44-
#define ESP32_PWM_VERSION "ESP32_PWM v1.1.0"
45+
#define ESP32_PWM_VERSION "ESP32_PWM v1.1.1"
4546
#endif
4647

4748
#ifndef _PWM_LOGLEVEL_
@@ -123,7 +124,8 @@ class ESP32_PWM_ISR
123124
return -1;
124125
}
125126

126-
return setupPWMChannel(pin, period, dutycycle, (void *) StartCallback, (void *) StopCallback);
127+
return setupPWMChannel(pin, period, dutycycle, (void *) StartCallback, (void *) StopCallback);
128+
//return 0;
127129
}
128130

129131
// period in us

0 commit comments

Comments
 (0)