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

Commit

Permalink
v1.2.3 to fix DutyCycle bug
Browse files Browse the repository at this point in the history
### Releases v1.2.3

1. Fix `DutyCycle` bug. Check [float precisison of DutyCycle only sometimes working #3](#3)
2. Fix `New Period` display bug. Check [random dropouts #4](#4)
3. Update examples
  • Loading branch information
khoih-prog authored Mar 3, 2022
1 parent b0229b7 commit 497d6c9
Show file tree
Hide file tree
Showing 23 changed files with 81 additions and 58 deletions.
45 changes: 29 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -421,7 +421,7 @@ The following is the sample terminal output when running example [ISR_16_PWMs_Ar

```
Starting ISR_4_PWMs_Array_Complex on SAMD_NANO_33_IOT
SAMD_Slow_PWM v1.2.2
SAMD_Slow_PWM v1.2.3
Starting ITimer OK, micros() = 2750362
Channel : 0 Period : 1000000 OnTime : 50000 Start_Time : 2750883
Channel : 1 Period : 500000 OnTime : 50000 Start_Time : 2751343
Expand Down Expand Up @@ -458,7 +458,7 @@ The following is the sample terminal output when running example [ISR_16_PWMs_Ar

```
Starting ISR_16_PWMs_Array_Complex on ITSYBITSY_M4
SAMD_Slow_PWM v1.2.2
SAMD_Slow_PWM v1.2.3
Starting ITimer OK, micros() = 3830244
Channel : 0 Period : 1000000 OnTime : 50000 Start_Time : 3830538
Channel : 1 Period : 500000 OnTime : 50000 Start_Time : 3830903
Expand Down Expand Up @@ -521,7 +521,7 @@ The following is the sample terminal output when running example [ISR_4_PWMs_Arr

```
Starting ISR_16_PWMs_Array_Complex on SEEED_XIAO_M0
SAMD_Slow_PWM v1.2.2
SAMD_Slow_PWM v1.2.3
Starting ITimer OK, micros() = 2681651
Channel : 0 Period : 1000000 OnTime : 50000 Start_Time : 2682003
Channel : 1 Period : 500000 OnTime : 50000 Start_Time : 2682003
Expand All @@ -547,14 +547,24 @@ The following is the sample terminal output when running example [ISR_Modify_PWM

```
Starting ISR_Modify_PWM on SAMD_NANO_33_IOT
SAMD_Slow_PWM v1.2.2
Starting ITimer OK, micros() = 3070515
Using PWM Freq = 1.00, PWM DutyCycle = 50.00
Channel : 0 Period : 1000000 OnTime : 500000 Start_Time : 3071411
Channel : 0 New Period : 500000 OnTime : 450000 Start_Time : 13071416
Channel : 0 New Period : 1000000 OnTime : 500000 Start_Time : 23071416
Channel : 0 New Period : 500000 OnTime : 450000 Start_Time : 32571416
Channel : 0 New Period : 1000000 OnTime : 500000 Start_Time : 43071416
SAMD_Slow_PWM v1.2.3
[PWM] SAMDTimerInterrupt: F_CPU (MHz) = 48 , TIMER_HZ = 48
[PWM] TC3_Timer::startTimer _Timer = 0x 42002c00 , TC3 = 0x 42002c00
Starting ITimer OK, micros() = 3761339
Using PWM Freq = 200.00, PWM DutyCycle = 1.00
Channel : 0 Period : 5000 OnTime : 50 Start_Time : 3762307
Channel : 0 Period : 10000 OnTime : 555 Start_Time : 13762340
Channel : 0 Period : 5000 OnTime : 50 Start_Time : 23757340
Channel : 0 Period : 10000 OnTime : 555 Start_Time : 33762390
Channel : 0 Period : 5000 OnTime : 50 Start_Time : 43757390
Channel : 0 Period : 10000 OnTime : 555 Start_Time : 53762390
Channel : 0 Period : 5000 OnTime : 50 Start_Time : 63767390
Channel : 0 Period : 10000 OnTime : 555 Start_Time : 73767390
Channel : 0 Period : 5000 OnTime : 50 Start_Time : 83762390
Channel : 0 Period : 10000 OnTime : 555 Start_Time : 93767390
Channel : 0 Period : 5000 OnTime : 50 Start_Time : 103762390
Channel : 0 Period : 10000 OnTime : 555 Start_Time : 113772440
Channel : 0 Period : 5000 OnTime : 50 Start_Time : 123767440
```

---
Expand All @@ -565,7 +575,7 @@ The following is the sample terminal output when running example [ISR_Changing_P

```
Starting ISR_Changing_PWM on SAMD_NANO_33_IOT
SAMD_Slow_PWM v1.2.2
SAMD_Slow_PWM v1.2.3
Starting ITimer OK, micros() = 2820370
Using PWM Freq = 1.00, PWM DutyCycle = 50.00
Channel : 0 Period : 1000000 OnTime : 500000 Start_Time : 2821335
Expand All @@ -591,7 +601,7 @@ The following is the sample terminal output when running example [ISR_Modify_PWM

```
Starting ISR_Modify_PWM on ITSYBITSY_M4
SAMD_Slow_PWM v1.2.2
SAMD_Slow_PWM v1.2.3
Starting ITimer OK, micros() = 3320212
Using PWM Freq = 1.00, PWM DutyCycle = 50.00
Channel : 0 Period : 1000000 OnTime : 500000 Start_Time : 3320837
Expand Down Expand Up @@ -622,7 +632,7 @@ The following is the sample terminal output when running example [ISR_Changing_P

```
Starting ISR_Changing_PWM on ITSYBITSY_M4
SAMD_Slow_PWM v1.2.2
SAMD_Slow_PWM v1.2.3
Starting ITimer OK, micros() = 3660252
Using PWM Freq = 1.00, PWM DutyCycle = 50.00
Channel : 0 Period : 1000000 OnTime : 500000 Start_Time : 3660870
Expand Down Expand Up @@ -692,11 +702,14 @@ Submit issues to: [SAMD_Slow_PWM issues](https://github.com/khoih-prog/SAMD_Slow

Many thanks for everyone for bug reporting, new feature suggesting, testing and contributing to the development of this library.

1. [toniMephis](https://github.com/toniMephis) to report issue [missing header #2](https://github.com/khoih-prog/SAMD_Slow_PWM/issues/2) leading to version v1.2.2.
1. [toniMephis](https://github.com/toniMephis) to report

- issue [missing header #2](https://github.com/khoih-prog/SAMD_Slow_PWM/issues/2) leading to version v1.2.2
- issues [float precisison of DutyCycle only sometimes working #3](https://github.com/khoih-prog/SAMD_Slow_PWM/issues/3) and [random dropouts #4](https://github.com/khoih-prog/SAMD_Slow_PWM/issues/4) leading to version v1.2.3

<table>
<tr>
<td align="center"><a href="https://github.com/toniMephis"><img src="https://github.com/toniMephis.png" width="100px;" alt="toniMephis"/><br /><sub><b>toniMephis</b></sub></a><br /></td>
<td align="center"><a href="https://github.com/toniMephis"><img src="https://github.com/toniMephis.png" width="100px;" alt="toniMephis"/><br /><sub><b>⭐️ toniMephis</b></sub></a><br /></td>
</tr>
</table>

Expand Down
8 changes: 8 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
## Table of Contents

* [Changelog](#changelog)
* [Releases v1.2.3](#releases-v123)
* [Releases v1.2.2](#releases-v122)
* [Releases v1.2.1](#releases-v121)
* [Releases v1.2.0](#releases-v120)
Expand All @@ -23,6 +24,13 @@

## Changelog

### Releases v1.2.3

1. Fix `DutyCycle` bug. Check [float precisison of DutyCycle only sometimes working #3](https://github.com/khoih-prog/SAMD_Slow_PWM/issues/3)
2. Fix `New Period` display bug. Check [random dropouts #4](https://github.com/khoih-prog/SAMD_Slow_PWM/issues/4)
3. Update examples


### Releases v1.2.2

1. Use correct `PWM_Generic_Debug.h` file. Check [missing header #2](https://github.com/khoih-prog/SAMD_Slow_PWM/issues/2)
Expand Down
3 changes: 1 addition & 2 deletions examples/SAMD21/ISR_4_PWMs_Array/ISR_4_PWMs_Array.ino
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@

// These define's must be placed at the beginning before #include "SAMD_Slow_PWM.h"
// _PWM_LOGLEVEL_ from 0 to 4
// Don't define _PWM_LOGLEVEL_ > 0. Only for special ISR debugging only. Can hang the system.
#define _PWM_LOGLEVEL_ 4
#define _PWM_LOGLEVEL_ 3

#define USING_MICROS_RESOLUTION true //false

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,7 @@

// These define's must be placed at the beginning before #include "SAMD_Slow_PWM.h"
// _PWM_LOGLEVEL_ from 0 to 4
// Don't define _PWM_LOGLEVEL_ > 0. Only for special ISR debugging only. Can hang the system.
#define _PWM_LOGLEVEL_ 4
#define _PWM_LOGLEVEL_ 1

#define USING_MICROS_RESOLUTION true //false

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@

// These define's must be placed at the beginning before #include "SAMD_Slow_PWM.h"
// _PWM_LOGLEVEL_ from 0 to 4
// Don't define _PWM_LOGLEVEL_ > 0. Only for special ISR debugging only. Can hang the system.
#define _PWM_LOGLEVEL_ 4
#define _PWM_LOGLEVEL_ 3

#define USING_MICROS_RESOLUTION true //false

Expand Down
3 changes: 1 addition & 2 deletions examples/SAMD21/ISR_Changing_PWM/ISR_Changing_PWM.ino
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@

// These define's must be placed at the beginning before #include "SAMD_Slow_PWM.h"
// _PWM_LOGLEVEL_ from 0 to 4
// Don't define _PWM_LOGLEVEL_ > 0. Only for special ISR debugging only. Can hang the system.
#define _PWM_LOGLEVEL_ 4
#define _PWM_LOGLEVEL_ 3

#define USING_MICROS_RESOLUTION true //false

Expand Down
15 changes: 7 additions & 8 deletions examples/SAMD21/ISR_Modify_PWM/ISR_Modify_PWM.ino
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@

// These define's must be placed at the beginning before #include "SAMD_Slow_PWM.h"
// _PWM_LOGLEVEL_ from 0 to 4
// Don't define _PWM_LOGLEVEL_ > 0. Only for special ISR debugging only. Can hang the system.
#define _PWM_LOGLEVEL_ 4
#define _PWM_LOGLEVEL_ 3

#define USING_MICROS_RESOLUTION true //false

Expand Down Expand Up @@ -82,19 +81,19 @@ void TimerHandler()
uint32_t PWM_Pin = LED_BUILTIN;

// You can assign any interval for any timer here, in Hz
float PWM_Freq1 = 1.0f;
float PWM_Freq1 = 200.0f; //1.0f;
// You can assign any interval for any timer here, in Hz
float PWM_Freq2 = 2.0f;
float PWM_Freq2 = 100.0f; //2.0f;

// You can assign any interval for any timer here, in microseconds
uint32_t PWM_Period1 = 1000000 / PWM_Freq1;
// You can assign any interval for any timer here, in microseconds
uint32_t PWM_Period2 = 1000000 / PWM_Freq2;

// You can assign any duty_cycle for any PWM here, from 0-100
float PWM_DutyCycle1 = 50.0;
float PWM_DutyCycle1 = 1.0f; //50.0f;
// You can assign any duty_cycle for any PWM here, from 0-100
float PWM_DutyCycle2 = 90.0;
float PWM_DutyCycle2 = 5.55f; //90.0f;

// Channel number used to identify associated channel
int channelNum;
Expand Down Expand Up @@ -144,8 +143,8 @@ void changePWM()
{
static uint8_t count = 1;

double PWM_Freq;
uint32_t PWM_DutyCycle;
float PWM_Freq;
float PWM_DutyCycle;

if (count++ % 2)
{
Expand Down
4 changes: 2 additions & 2 deletions examples/SAMD21/multiFileProject/multiFileProject.ino
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
#error This code is designed to run on SAMD21 platform! Please check your Tools->Board setting.
#endif

#define SAMD_SLOW_PWM_VERSION_MIN_TARGET "SAMD_Slow_PWM v1.2.1"
#define SAMD_SLOW_PWM_VERSION_MIN 1002001
#define SAMD_SLOW_PWM_VERSION_MIN_TARGET "SAMD_Slow_PWM v1.2.3"
#define SAMD_SLOW_PWM_VERSION_MIN 1002003

#include "multiFileProject.h"

Expand Down
2 changes: 1 addition & 1 deletion examples/SAMD51/ISR_16_PWMs_Array/ISR_16_PWMs_Array.ino
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
// These define's must be placed at the beginning before #include "ESP32_PWM.h"
// _PWM_LOGLEVEL_ from 0 to 4
// Don't define _PWM_LOGLEVEL_ > 0. Only for special ISR debugging only. Can hang the system.
#define _PWM_LOGLEVEL_ 4
#define _PWM_LOGLEVEL_ 3

#define USING_MICROS_RESOLUTION true //false

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
// These define's must be placed at the beginning before #include "ESP32_PWM.h"
// _PWM_LOGLEVEL_ from 0 to 4
// Don't define _PWM_LOGLEVEL_ > 0. Only for special ISR debugging only. Can hang the system.
#define _PWM_LOGLEVEL_ 4
#define _PWM_LOGLEVEL_ 1

#define USING_MICROS_RESOLUTION true //false

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
// These define's must be placed at the beginning before #include "ESP32_PWM.h"
// _PWM_LOGLEVEL_ from 0 to 4
// Don't define _PWM_LOGLEVEL_ > 0. Only for special ISR debugging only. Can hang the system.
#define _PWM_LOGLEVEL_ 4
#define _PWM_LOGLEVEL_ 3

#define USING_MICROS_RESOLUTION true //false

Expand Down
2 changes: 1 addition & 1 deletion examples/SAMD51/ISR_Changing_PWM/ISR_Changing_PWM.ino
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
// These define's must be placed at the beginning before #include "ESP32_PWM.h"
// _PWM_LOGLEVEL_ from 0 to 4
// Don't define _PWM_LOGLEVEL_ > 0. Only for special ISR debugging only. Can hang the system.
#define _PWM_LOGLEVEL_ 4
#define _PWM_LOGLEVEL_ 3

#define USING_MICROS_RESOLUTION true //false

Expand Down
6 changes: 3 additions & 3 deletions examples/SAMD51/ISR_Modify_PWM/ISR_Modify_PWM.ino
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
// These define's must be placed at the beginning before #include "ESP32_PWM.h"
// _PWM_LOGLEVEL_ from 0 to 4
// Don't define _PWM_LOGLEVEL_ > 0. Only for special ISR debugging only. Can hang the system.
#define _PWM_LOGLEVEL_ 4
#define _PWM_LOGLEVEL_ 3

#define USING_MICROS_RESOLUTION true //false

Expand Down Expand Up @@ -137,8 +137,8 @@ void changePWM()
{
static uint8_t count = 1;

double PWM_Freq;
uint32_t PWM_DutyCycle;
float PWM_Freq;
float PWM_DutyCycle;

if (count++ % 2)
{
Expand Down
4 changes: 2 additions & 2 deletions examples/SAMD51/multiFileProject/multiFileProject.ino
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
#error This code is designed to run on SAMD51 platform! Please check your Tools->Board setting.
#endif

#define SAMD_SLOW_PWM_VERSION_MIN_TARGET "SAMD_Slow_PWM v1.2.1"
#define SAMD_SLOW_PWM_VERSION_MIN 1002001
#define SAMD_SLOW_PWM_VERSION_MIN_TARGET "SAMD_Slow_PWM v1.2.3"
#define SAMD_SLOW_PWM_VERSION_MIN 1002003

#include "multiFileProject.h"

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": "SAMD_Slow_PWM",
"version": "1.2.2",
"version": "1.2.3",
"keywords": "timing, device, control, timer, interrupt, hardware, isr, isr-based, hardware-timer, isr-timer, isr-based-timer, mission-critical, accuracy, precise, non-blocking, samd, samd21, samd51, nano-33-iot",
"description": "This library enables you to use Hardware Timers on SAMD21/SAMD51 boards to create and output PWM to pins. These PWM channels, using SAMD21/SAMD51 Hardware Timers, 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 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're 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. Max PWM frequency is limited at 1000Hz. Now you can change the PWM settings on-the-fly",
"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=SAMD_Slow_PWM
version=1.2.2
version=1.2.3
author=Khoi Hoang <khoih.prog@gmail.com>
maintainer=Khoi Hoang <khoih.prog@gmail.com>
sentence=This library enables you to use Hardware Timers on SAMD21/SAMD51 boards to create and output PWM to pins.
Expand Down
3 changes: 2 additions & 1 deletion src/PWM_Generic_Debug.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
Therefore, their executions are not blocked by bad-behaving functions / tasks.
This important feature is absolutely necessary for mission-critical tasks.
Version: 1.2.2
Version: 1.2.3
Version Modified By Date Comments
------- ----------- ---------- -----------
Expand All @@ -21,6 +21,7 @@
1.2.0 K Hoang 31/01/2022 Fix multiple-definitions linker error. Improve accuracy. Change DutyCycle update
1.2.1 K Hoang 01/02/2022 Use float for DutyCycle and Freq, uint32_t for period
1.2.2 K Hoang 02/03/2022 Use correct PWM_Generic_Debug.h file. Display informational warning when debug level > 3
1.2.3 K Hoang 03/03/2022 Fix `DutyCycle` and `New Period` display bugs
*****************************************************************************************************************************/

#pragma once
Expand Down
3 changes: 2 additions & 1 deletion src/SAMD_Slow_PWM.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
Therefore, their executions are not blocked by bad-behaving functions / tasks.
This important feature is absolutely necessary for mission-critical tasks.
Version: 1.2.2
Version: 1.2.3
Version Modified By Date Comments
------- ----------- ---------- -----------
Expand All @@ -21,6 +21,7 @@
1.2.0 K Hoang 31/01/2022 Fix multiple-definitions linker error. Improve accuracy. Change DutyCycle update
1.2.1 K Hoang 01/02/2022 Use float for DutyCycle and Freq, uint32_t for period
1.2.2 K Hoang 02/03/2022 Use correct PWM_Generic_Debug.h file. Display informational warning when debug level > 3
1.2.3 K Hoang 03/03/2022 Fix `DutyCycle` and `New Period` display bugs
*****************************************************************************************************************************/

#pragma once
Expand Down
9 changes: 5 additions & 4 deletions src/SAMD_Slow_PWM.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
Therefore, their executions are not blocked by bad-behaving functions / tasks.
This important feature is absolutely necessary for mission-critical tasks.
Version: 1.2.2
Version: 1.2.3
Version Modified By Date Comments
------- ----------- ---------- -----------
Expand All @@ -21,6 +21,7 @@
1.2.0 K Hoang 31/01/2022 Fix multiple-definitions linker error. Improve accuracy. Change DutyCycle update
1.2.1 K Hoang 01/02/2022 Use float for DutyCycle and Freq, uint32_t for period
1.2.2 K Hoang 02/03/2022 Use correct PWM_Generic_Debug.h file. Display informational warning when debug level > 3
1.2.3 K Hoang 03/03/2022 Fix `DutyCycle` and `New Period` display bugs
*****************************************************************************************************************************/

#pragma once
Expand Down Expand Up @@ -145,13 +146,13 @@
#include "Arduino.h"

#ifndef SAMD_SLOW_PWM_VERSION
#define SAMD_SLOW_PWM_VERSION "SAMD_Slow_PWM v1.2.2"
#define SAMD_SLOW_PWM_VERSION "SAMD_Slow_PWM v1.2.3"

#define SAMD_SLOW_PWM_VERSION_MAJOR 1
#define SAMD_SLOW_PWM_VERSION_MINOR 2
#define SAMD_SLOW_PWM_VERSION_PATCH 2
#define SAMD_SLOW_PWM_VERSION_PATCH 3

#define SAMD_SLOW_PWM_VERSION_INT 1002002
#define SAMD_SLOW_PWM_VERSION_INT 1002003
#endif

#include "PWM_Generic_Debug.h"
Expand Down
3 changes: 2 additions & 1 deletion src/SAMD_Slow_PWM_ISR.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
Therefore, their executions are not blocked by bad-behaving functions / tasks.
This important feature is absolutely necessary for mission-critical tasks.
Version: 1.2.2
Version: 1.2.3
Version Modified By Date Comments
------- ----------- ---------- -----------
Expand All @@ -21,6 +21,7 @@
1.2.0 K Hoang 31/01/2022 Fix multiple-definitions linker error. Improve accuracy. Change DutyCycle update
1.2.1 K Hoang 01/02/2022 Use float for DutyCycle and Freq, uint32_t for period
1.2.2 K Hoang 02/03/2022 Use correct PWM_Generic_Debug.h file. Display informational warning when debug level > 3
1.2.3 K Hoang 03/03/2022 Fix `DutyCycle` and `New Period` display bugs
*****************************************************************************************************************************/

#pragma once
Expand Down
Loading

0 comments on commit 497d6c9

Please sign in to comment.