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

Commit 5ab04b3

Browse files
authored
v1.2.0 to work with ESP32 core v2.0.1+
### Releases v1.2.0 1. Fix breaking issue caused by **ESP32 core v2.0.1+** by increasing `TIMER_INTERVAL_MICRO` to `12uS` from `10uS`. Tested OK with ESP32 core v2.0.3 now
1 parent e05bb5d commit 5ab04b3

11 files changed

+59
-147
lines changed

CONTRIBUTING.md

Lines changed: 3 additions & 3 deletions
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.2)
18+
* `ESP32` Core Version (e.g. ESP32 core v2.0.3)
1919
* `ESP32` Board type (e.g. ESP32_DEV Module, etc.)
2020
* `ESP32-S2` Board type (e.g. ESP32S2_DEV Module, ESP32_S2_Saola, etc.)
2121
* `ESP32_S3` Board type (e.g. ESP32S3_DEV, ESP32_S3_BOX, UM TINYS3, UM PROS3, UM FEATHERS3, etc.)
@@ -31,10 +31,10 @@ Please ensure to specify the following:
3131

3232
```
3333
Arduino IDE version: 1.8.19
34-
ESP32 core v2.0.2
34+
ESP32 core v2.0.3
3535
ESP32S3_DEV Module
3636
OS: Ubuntu 20.04 LTS
37-
Linux xy-Inspiron-3593 5.4.0-99-generic #112-Ubuntu SMP Thu Feb 3 13:50:55 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux
37+
Linux xy-Inspiron-3593 5.13.0-40-generic #45~20.04.1-Ubuntu SMP Mon Apr 4 09:38:31 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux
3838
3939
Context:
4040
I encountered a crash while trying to use the Timer Interrupt.

README.md

Lines changed: 23 additions & 125 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
## Table of Contents
1515

16+
* [Important Change from v1.2.0](#Important-Change-from-v120)
1617
* [Important Change from v1.1.0](#Important-Change-from-v110)
1718
* [Why do we need this ESP32_New_ISR_Servo library](#why-do-we-need-this-esp32_new_isr_servo-library)
1819
* [Features](#features)
@@ -62,6 +63,11 @@
6263
---
6364
---
6465

66+
### Important Change from v1.2.0
67+
68+
Please use the **new v1.2.0+** for **ESP32 core v2.0.1+**, or the library won't work anymore.
69+
70+
6571
### Important Change from v1.1.0
6672

6773
Please have a look at [HOWTO Fix `Multiple Definitions` Linker Error](#howto-fix-multiple-definitions-linker-error)
@@ -117,7 +123,7 @@ This [**ESP32_New_ISR_Servo** library](https://github.com/khoih-prog/ESP32_New_I
117123
## Prerequisites
118124

119125
1. [`Arduino IDE 1.8.19+` for Arduino](https://github.com/arduino/Arduino). [![GitHub release](https://img.shields.io/github/release/arduino/Arduino.svg)](https://github.com/arduino/Arduino/releases/latest)
120-
2. [`ESP32 Core 2.0.2+`](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/)
126+
2. [`ESP32 Core 2.0.3+`](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/)
121127

122128

123129
---
@@ -403,118 +409,8 @@ void loop()
403409

404410
#### 1. File [ESP32_New_ISR_MultiServos.ino](examples/ESP32_New_ISR_MultiServos/ESP32_New_ISR_MultiServos.ino)
405411

406-
```cpp
407-
#if !defined(ESP32)
408-
#error This code is intended to run on the ESP32 platform! Please check your Tools->Board setting.
409-
#endif
410-
411-
#define TIMER_INTERRUPT_DEBUG 0
412-
#define ISR_SERVO_DEBUG 1
413-
414-
// For ESP32_C3, select ESP32 timer number (0-1)
415-
// For ESP32 and ESP32_S2, select ESP32 timer number (0-3)
416-
#if defined( ARDUINO_ESP32C3_DEV )
417-
#define USE_ESP32_TIMER_NO 1
418-
#else
419-
#define USE_ESP32_TIMER_NO 3
420-
#endif
421-
422-
// To be included only in main(), .ino with setup() to avoid `Multiple Definitions` Linker Error
423-
#include "ESP32_New_ISR_Servo.h"
424-
425-
//See file .../hardware/espressif/esp32/variants/(esp32|doitESP32devkitV1)/pins_arduino.h
426-
#define LED_BUILTIN 2 // Pin D2 mapped to pin GPIO2/ADC12 of ESP32, control on-board LED
427-
#define PIN_LED 2 // Pin D2 mapped to pin GPIO2/ADC12 of ESP32, control on-board LED
428-
429-
#define PIN_D0 0 // Pin D0 mapped to pin GPIO0/BOOT/ADC11/TOUCH1 of ESP32
430-
#define PIN_D1 1 // Pin D1 mapped to pin GPIO1/TX0 of ESP32
431-
#define PIN_D2 2 // Pin D2 mapped to pin GPIO2/ADC12/TOUCH2 of ESP32
432-
#define PIN_D3 3 // Pin D3 mapped to pin GPIO3/RX0 of ESP32
433-
#define PIN_D4 4 // Pin D4 mapped to pin GPIO4/ADC10/TOUCH0 of ESP32
434-
#define PIN_D5 5 // Pin D5 mapped to pin GPIO5/SPISS/VSPI_SS of ESP32
435-
#define PIN_D6 6 // Pin D6 mapped to pin GPIO6/FLASH_SCK of ESP32
436-
#define PIN_D7 7 // Pin D7 mapped to pin GPIO7/FLASH_D0 of ESP32
437-
#define PIN_D8 8 // Pin D8 mapped to pin GPIO8/FLASH_D1 of ESP32
438-
#define PIN_D9 9 // Pin D9 mapped to pin GPIO9/FLASH_D2 of ESP32
439-
440-
// Published values for SG90 servos; adjust if needed
441-
#define MIN_MICROS 800 //544
442-
#define MAX_MICROS 2450
443-
444-
int servoIndex1 = -1;
445-
int servoIndex2 = -1;
446-
447-
void setup()
448-
{
449-
Serial.begin(115200);
450-
while (!Serial);
451-
452-
delay(500);
453-
454-
Serial.print(F("\nStarting ESP32_New_ISR_MultiServos on ")); Serial.println(ARDUINO_BOARD);
455-
Serial.println(ESP32_NEW_ISR_SERVO_VERSION);
456-
457-
//Select ESP32 timer USE_ESP32_TIMER_NO
458-
ESP32_ISR_Servos.useTimer(USE_ESP32_TIMER_NO);
459-
460-
servoIndex1 = ESP32_ISR_Servos.setupServo(PIN_D2, MIN_MICROS, MAX_MICROS);
461-
servoIndex2 = ESP32_ISR_Servos.setupServo(PIN_D3, MIN_MICROS, MAX_MICROS);
412+
https://github.com/khoih-prog/ESP32_New_ISR_Servo/blob/e05bb5d4fc2abf2bd5551388f64414626047d90b/examples/ESP32_New_ISR_MultiServos/ESP32_New_ISR_MultiServos.ino#L65-L174
462413

463-
if (servoIndex1 != -1)
464-
Serial.println(F("Setup Servo1 OK"));
465-
else
466-
Serial.println(F("Setup Servo1 failed"));
467-
468-
if (servoIndex2 != -1)
469-
Serial.println(F("Setup Servo2 OK"));
470-
else
471-
Serial.println(F("Setup Servo2 failed"));
472-
}
473-
474-
void loop()
475-
{
476-
int position;
477-
478-
if ( ( servoIndex1 != -1) && ( servoIndex2 != -1) )
479-
{
480-
for (position = 0; position <= 180; position++)
481-
{
482-
// goes from 0 degrees to 180 degrees
483-
// in steps of 1 degree
484-
485-
if (position % 30 == 0)
486-
{
487-
Serial.print(F("Servo1 pos = ")); Serial.print(position);
488-
Serial.print(F(", Servo2 pos = ")); Serial.println(180 - position);
489-
}
490-
491-
ESP32_ISR_Servos.setPosition(servoIndex1, position);
492-
ESP32_ISR_Servos.setPosition(servoIndex2, 180 - position);
493-
// waits 30ms for the servo to reach the position
494-
delay(30);
495-
}
496-
497-
delay(5000);
498-
499-
for (position = 180; position >= 0; position--)
500-
{
501-
// goes from 180 degrees to 0 degrees
502-
if (position % 30 == 0)
503-
{
504-
Serial.print(F("Servo1 pos = ")); Serial.print(position);
505-
Serial.print(F(", Servo2 pos = ")); Serial.println(180 - position);
506-
}
507-
508-
ESP32_ISR_Servos.setPosition(servoIndex1, position);
509-
ESP32_ISR_Servos.setPosition(servoIndex2, 180 - position);
510-
// waits 30ms for the servo to reach the position
511-
delay(30);
512-
}
513-
514-
delay(5000);
515-
}
516-
}
517-
```
518414
---
519415
---
520416

@@ -524,7 +420,7 @@ void loop()
524420

525421
```
526422
Starting ESP32_New_MultipleRandomServos on ESP32S2_DEV
527-
ESP32_New_ISR_Servo v1.1.0
423+
ESP32_New_ISR_Servo v1.2.0
528424
[ISR_SERVO] ESP32_S2_TimerInterrupt: _timerNo = 3 , _fre = 1000000
529425
[ISR_SERVO] TIMER_BASE_CLK = 80000000 , TIMER_DIVIDER = 80
530426
[ISR_SERVO] _timerIndex = 1 , _timerGroup = 1
@@ -640,7 +536,7 @@ Servos sweeps from 0-180 degress
640536

641537
```
642538
Starting ESP32_New_ISR_MultiServos on ESP32S2_DEV
643-
ESP32_New_ISR_Servo v1.1.0
539+
ESP32_New_ISR_Servo v1.2.0
644540
[ISR_SERVO] ESP32_S2_TimerInterrupt: _timerNo = 3 , _fre = 1000000
645541
[ISR_SERVO] TIMER_BASE_CLK = 80000000 , TIMER_DIVIDER = 80
646542
[ISR_SERVO] _timerIndex = 1 , _timerGroup = 1
@@ -665,7 +561,7 @@ Servo1 pos = 180, Servo2 pos = 0
665561

666562
```
667563
Starting ESP32_New_MultipleRandomServos on ESP32S3_DEV
668-
ESP32_New_ISR_Servo v1.1.0
564+
ESP32_New_ISR_Servo v1.2.0
669565
[ISR_SERVO] ESP32_S3_TimerInterrupt: _timerNo = 3 , _fre = 1000000
670566
[ISR_SERVO] TIMER_BASE_CLK = 80000000 , TIMER_DIVIDER = 80
671567
[ISR_SERVO] _timerIndex = 1 , _timerGroup = 1
@@ -723,7 +619,7 @@ Servos idx = 0, act. pos. (deg) = [ISR_SERVO] Idx = 0
723619

724620
```
725621
Starting ESP32_New_ISR_MultiServos on ESP32S3_DEV
726-
ESP32_New_ISR_Servo v1.1.0
622+
ESP32_New_ISR_Servo v1.2.0
727623
[ISR_SERVO] ESP32_S3_TimerInterrupt: _timerNo = 3 , _fre = 1000000
728624
[ISR_SERVO] TIMER_BASE_CLK = 80000000 , TIMER_DIVIDER = 80
729625
[ISR_SERVO] _timerIndex = 1 , _timerGroup = 1
@@ -804,15 +700,17 @@ Submit issues to: [ESP32_New_ISR_Servo issues](https://github.com/khoih-prog/ESP
804700

805701
## DONE
806702

807-
1. Similar features for Arduino (UNO, Mega, etc...), ESP32 and ESP8266
808-
2. Add functions `getPosition()` and `getPulseWidth()`
809-
3. Optimize the code
810-
4. Add more complicated examples
811-
5. Add support to new `ESP32-S3` (ESP32S3_DEV, ESP32_S3_BOX, UM TINYS3, UM PROS3, UM FEATHERS3, etc.)
812-
6. Convert to h-only library.
813-
7. Optimize library code by using `reference-passing` instead of `value-passing`
814-
8. Improve accuracy by using `float`, instead of `uint32_t` for `position` in degrees
815-
9. Add example [multiFileProject](examples/multiFileProject) to demo for multiple-file project
703+
1. Similar features for Arduino (UNO, Mega, etc...), ESP32 and ESP8266
704+
2. Add functions `getPosition()` and `getPulseWidth()`
705+
3. Optimize the code
706+
4. Add more complicated examples
707+
5. Add support to new `ESP32-S3` (ESP32S3_DEV, ESP32_S3_BOX, UM TINYS3, UM PROS3, UM FEATHERS3, etc.)
708+
6. Convert to h-only library.
709+
7. Optimize library code by using `reference-passing` instead of `value-passing`
710+
8. Improve accuracy by using `float`, instead of `uint32_t` for `position` in degrees
711+
9. Add example [multiFileProject](examples/multiFileProject) to demo for multiple-file project
712+
10. Fix breaking issue caused by **ESP32 core v2.0.1+** by increasing `TIMER_INTERVAL_MICRO` to `12uS` from `10uS`
713+
816714

817715
---
818716
---

changelog.md

Lines changed: 6 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.2.0](#releases-v120)
1516
* [Releases v1.1.0](#releases-v110)
1617
* [Releases v1.0.0](#releases-v100)
1718

@@ -20,6 +21,11 @@
2021

2122
## Changelog
2223

24+
### Releases v1.2.0
25+
26+
1. Fix breaking issue caused by **ESP32 core v2.0.1+** by increasing `TIMER_INTERVAL_MICRO` to `12uS` from `10uS`. Tested OK with ESP32 core v2.0.3 now
27+
28+
2329
### Releases v1.1.0
2430

2531
1. Add support to new `ESP32-S3` (ESP32S3_DEV, ESP32_S3_BOX, UM TINYS3, UM PROS3, UM FEATHERS3, etc.)

library.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
{
22
"name": "ESP32_New_ISR_Servo",
3-
"version": "1.1.0",
3+
"version": "1.2.0",
44
"keywords": "timer, interrupt, isr, hardware, servo, isr-based-servo, servo-control, esp32, esp32-s2, esp32-s3, esp32-c3, mission-critical, precise, non-blocking",
5-
"description": "This library enables you to use 1 Hardware Timer on an ESP32, ESP32_S2, ESP32_C3-based board to control up to 16 or more servo motors.",
5+
"description": "This library enables you to use 1 Hardware Timer on an ESP32, ESP32_S2, ESP32_C3-based board to control up to 16 or more servo motors. Tested OK with ESP32 core v2.0.3",
66
"authors":
77
{
88
"name": "Khoi Hoang",

library.properties

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
name=ESP32_New_ISR_Servo
2-
version=1.1.0
2+
version=1.2.0
33
author=Khoi Hoang <[email protected]>
44
maintainer=Khoi Hoang <[email protected]>
55
license=MIT
66
sentence=This library enables you to use Interrupt from Hardware Timers on ESP32, ESP32_S2, ESP32_S3, ESP32_C3 boards to control multiple servo motors.
7-
paragraph=This library enables you to use 1 Hardware Timer on ESP32, ESP32_S2, ESP32_S3, ESP32_C3-based boards to control 16 or more servo motors.
7+
paragraph=This library enables you to use 1 Hardware Timer on ESP32, ESP32_S2, ESP32_S3, ESP32_C3-based boards to control 16 or more servo motors. Tested OK with ESP32 core v2.0.3
88
category=Device Control
99
url=https://github.com/khoih-prog/ESP32_New_ISR_Servo
1010
architectures=esp32

platformio/platformio.ini

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ upload_speed = 921600
3131

3232
; Checks for the compatibility with frameworks and dev/platforms
3333
lib_compat_mode = strict
34+
lib_ldf_mode = chain+
35+
;lib_ldf_mode = deep+
3436

3537
lib_deps =
3638

src/ESP32_New_FastTimerInterrupt.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,13 @@
2727
Based on BlynkTimer.h
2828
Author: Volodymyr Shymanskyy
2929
30-
Version: 1.1.0
30+
Version: 1.2.0
3131
3232
Version Modified By Date Comments
3333
------- ----------- ---------- -----------
3434
1.0.0 K Hoang 15/08/2021 Initial coding for ESP32, ESP32_S2, ESP32_C3 boards with ESP32 core v2.0.0-rc1+
35-
1.1.0 K Hoang 12/02/2022 Add support to new ESP32-S3. Convert to h-only library. Optimize code.
35+
1.1.0 K Hoang 12/02/2022 Add support to new ESP32-S3. Convert to h-only library. Optimize code
36+
1.2.0 K Hoang 08/05/2022 Fix issue with core v2.0.1+
3637
*****************************************************************************************************************************/
3738

3839
#pragma once

src/ESP32_New_ISR_Servo.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,13 @@
2727
Based on BlynkTimer.h
2828
Author: Volodymyr Shymanskyy
2929
30-
Version: 1.1.0
30+
Version: 1.2.0
3131
3232
Version Modified By Date Comments
3333
------- ----------- ---------- -----------
3434
1.0.0 K Hoang 15/08/2021 Initial coding for ESP32, ESP32_S2, ESP32_C3 boards with ESP32 core v2.0.0-rc1+
35-
1.1.0 K Hoang 12/02/2022 Add support to new ESP32-S3. Convert to h-only library. Optimize code.
35+
1.1.0 K Hoang 12/02/2022 Add support to new ESP32-S3. Convert to h-only library. Optimize code
36+
1.2.0 K Hoang 08/05/2022 Fix issue with core v2.0.1+
3637
*****************************************************************************************************************************/
3738

3839
#pragma once

src/ESP32_New_ISR_Servo.hpp

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,13 @@
2727
Based on BlynkTimer.h
2828
Author: Volodymyr Shymanskyy
2929
30-
Version: 1.1.0
30+
Version: 1.2.0
3131
3232
Version Modified By Date Comments
3333
------- ----------- ---------- -----------
3434
1.0.0 K Hoang 15/08/2021 Initial coding for ESP32, ESP32_S2, ESP32_C3 boards with ESP32 core v2.0.0-rc1+
35-
1.1.0 K Hoang 12/02/2022 Add support to new ESP32-S3. Convert to h-only library. Optimize code.
35+
1.1.0 K Hoang 12/02/2022 Add support to new ESP32-S3. Convert to h-only library. Optimize code
36+
1.2.0 K Hoang 08/05/2022 Fix issue with core v2.0.1+
3637
*****************************************************************************************************************************/
3738

3839
#pragma once
@@ -60,13 +61,13 @@
6061
#endif
6162

6263
#ifndef ESP32_NEW_ISR_SERVO_VERSION
63-
#define ESP32_NEW_ISR_SERVO_VERSION "ESP32_New_ISR_Servo v1.1.0"
64+
#define ESP32_NEW_ISR_SERVO_VERSION "ESP32_New_ISR_Servo v1.2.0"
6465

6566
#define ESP32_NEW_ISR_SERVO_VERSION_MAJOR 1
66-
#define ESP32_NEW_ISR_SERVO_VERSION_MINOR 1
67+
#define ESP32_NEW_ISR_SERVO_VERSION_MINOR 2
6768
#define ESP32_NEW_ISR_SERVO_VERSION_PATCH 0
6869

69-
#define ESP32_NEW_ISR_SERVO_VERSION_INT 1001000
70+
#define ESP32_NEW_ISR_SERVO_VERSION_INT 1002000
7071
#endif
7172

7273
#include <stddef.h>
@@ -203,8 +204,9 @@ class ESP32_ISR_Servo
203204

204205
private:
205206

206-
// Use 10 microsecs timer, just fine enough to control Servo, normally requiring pulse width (PWM) 500-2000us in 20ms.
207-
#define TIMER_INTERVAL_MICRO 10
207+
// Use 10 microsecs timer => not working from core v2.0.1+
208+
// Use 12 microsecs timer now, just fine enough to control Servo, normally requiring pulse width (PWM) 500-2000us in 20ms.
209+
#define TIMER_INTERVAL_MICRO 12
208210

209211
void init()
210212
{

src/ESP32_New_ISR_Servo_Debug.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,13 @@
2727
Based on BlynkTimer.h
2828
Author: Volodymyr Shymanskyy
2929
30-
Version: 1.1.0
30+
Version: 1.2.0
3131
3232
Version Modified By Date Comments
3333
------- ----------- ---------- -----------
3434
1.0.0 K Hoang 15/08/2021 Initial coding for ESP32, ESP32_S2, ESP32_C3 boards with ESP32 core v2.0.0-rc1+
35-
1.1.0 K Hoang 12/02/2022 Add support to new ESP32-S3. Convert to h-only library. Optimize code.
35+
1.1.0 K Hoang 12/02/2022 Add support to new ESP32-S3. Convert to h-only library. Optimize code
36+
1.2.0 K Hoang 08/05/2022 Fix issue with core v2.0.1+
3637
*****************************************************************************************************************************/
3738

3839
#pragma once

0 commit comments

Comments
 (0)