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

Commit 446d873

Browse files
authored
v1.1.0 to modify PWM settings on-the-fly
### Releases v1.1.0 1. Add functions to modify PWM settings on-the-fly 2. Add example to demo how to modify PWM settings on-the-fly
1 parent 6f3124e commit 446d873

28 files changed

+1133
-163
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
Arduino SAMD Core Version 1.8.11
3232
SAMD_NANO_33_IOT
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 SAMD_Slow_PWM.

README.md

Lines changed: 127 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -34,18 +34,26 @@
3434
* [2. Set PWM Frequency, dutycycle, attach irqCallbackStartFunc and irqCallbackStopFunc functions](#2-Set-PWM-Frequency-dutycycle-attach-irqCallbackStartFunc-and-irqCallbackStopFunc-functions)
3535
* [Examples](#examples)
3636
* [For SAMD21](#For-SAMD21)
37-
* [ 1. ISR_16_PWMs_Array](examples/SAMD21/ISR_16_PWMs_Array)
38-
* [ 2. ISR_16_PWMs_Array_Complex](examples/SAMD21/ISR_16_PWMs_Array_Complex)
39-
* [ 3. ISR_16_PWMs_Array_Simple](examples/SAMD21/ISR_16_PWMs_Array_Simple)
37+
* [ 1. ISR_16_PWMs_Array](examples/SAMD21/ISR_16_PWMs_Array)
38+
* [ 2. ISR_16_PWMs_Array_Complex](examples/SAMD21/ISR_16_PWMs_Array_Complex)
39+
* [ 3. ISR_16_PWMs_Array_Simple](examples/SAMD21/ISR_16_PWMs_Array_Simple)
40+
* [ 4. ISR_Changing_PWM](examples/SAMD21/ISR_Changing_PWM)
41+
* [ 5. ISR_Modify_PWM](examples/SAMD21/ISR_Modify_PWM)
4042
* [For SAMD51](#For-SAMD51)
41-
* [ 1. ISR_16_PWMs_Array](examples/SAMD51/ISR_16_PWMs_Array)
42-
* [ 2. ISR_16_PWMs_Array_Complex](examples/SAMD51/ISR_16_PWMs_Array_Complex)
43-
* [ 3. ISR_16_PWMs_Array_Simple](examples/SAMD51/ISR_16_PWMs_Array_Simple)
43+
* [ 1. ISR_16_PWMs_Array](examples/SAMD51/ISR_16_PWMs_Array)
44+
* [ 2. ISR_16_PWMs_Array_Complex](examples/SAMD51/ISR_16_PWMs_Array_Complex)
45+
* [ 3. ISR_16_PWMs_Array_Simple](examples/SAMD51/ISR_16_PWMs_Array_Simple)
46+
* [ 4. ISR_Changing_PWM](examples/SAMD51/ISR_Changing_PWM)
47+
* [ 5. ISR_Modify_PWM](examples/SAMD51/ISR_Modify_PWM)
4448
* [Example SAMD51 ISR_16_PWMs_Array_Complex](#Example-SAMD51-ISR_16_PWMs_Array_Complex)
4549
* [Debug Terminal Output Samples](#debug-terminal-output-samples)
4650
* [1. ISR_16_PWMs_Array_Complex on SAMD_NANO_33_IOT](#1-ISR_16_PWMs_Array_Complex-on-SAMD_NANO_33_IOT)
4751
* [2. ISR_16_PWMs_Array_Complex on ITSYBITSY_M4](#2-ISR_16_PWMs_Array_Complex-on-ITSYBITSY_M4)
4852
* [3. ISR_16_PWMs_Array_Complex on SEEED_XIAO_M0](#3-ISR_16_PWMs_Array_Complex-on-SEEED_XIAO_M0)
53+
* [4. ISR_Modify_PWM on SAMD_NANO_33_IOT](#4-ISR_Modify_PWM-on-SAMD_NANO_33_IOT)
54+
* [5. ISR_Changing_PWM on SAMD_NANO_33_IOT](#5-ISR_Changing_PWM-on-SAMD_NANO_33_IOT)
55+
* [6. ISR_Modify_PWM on ITSYBITSY_M4](#6-ISR_Modify_PWM-on-ITSYBITSY_M4)
56+
* [7. ISR_Changing_PWM on ITSYBITSY_M4](#7-ISR_Changing_PWM-on-ITSYBITSY_M4)
4957
* [Debug](#debug)
5058
* [Troubleshooting](#troubleshooting)
5159
* [Issues](#issues)
@@ -132,7 +140,7 @@ The catch is **your function is now part of an ISR (Interrupt Service Routine),
132140
2. [`Arduino SAMD core 1.8.11+`](https://github.com/arduino/ArduinoCore-samd) for SAMD ARM Cortex-M0+ boards. [![GitHub release](https://img.shields.io/github/release/arduino/ArduinoCore-samd.svg)](https://github.com/arduino/ArduinoCore-samd/releases/latest)
133141
3. [`Adafruit SAMD core 1.7.5+`](https://github.com/adafruit/ArduinoCore-samd) for SAMD ARM Cortex-M0+ and M4 boards (Nano 33 IoT, etc.). [![GitHub release](https://img.shields.io/github/release/adafruit/ArduinoCore-samd.svg)](https://github.com/adafruit/ArduinoCore-samd/releases/latest)
134142
4. [`Seeeduino SAMD core 1.8.1+`](https://github.com/Seeed-Studio/ArduinoCore-samd) for SAMD21/SAMD51 boards (XIAO M0, Wio Terminal, etc.). [![Latest release](https://img.shields.io/github/release/Seeed-Studio/ArduinoCore-samd.svg)](https://github.com/Seeed-Studio/ArduinoCore-samd/releases/latest/)
135-
5. [`Sparkfun SAMD core 1.8.1+`](https://github.com/sparkfun/Arduino_Boards) for SAMD21/SAMD51 boards (SparkFun_RedBoard_Turbo, SparkFun_SAMD51_Thing_Plus, etc.).
143+
5. [`Sparkfun SAMD core 1.8.3+`](https://github.com/sparkfun/Arduino_Boards) for SAMD21/SAMD51 boards (SparkFun_RedBoard_Turbo, SparkFun_SAMD51_Thing_Plus, etc.).
136144

137145
6. To use with certain example
138146
- [`SimpleTimer library`](https://github.com/jfturcot/SimpleTimer) for [ISR_16_Timers_Array example](examples/ISR_16_Timers_Array).
@@ -319,12 +327,16 @@ void setup()
319327
1. [ISR_16_PWMs_Array](examples/SAMD21/ISR_16_PWMs_Array)
320328
2. [ISR_16_PWMs_Array_Complex](examples/SAMD21/ISR_16_PWMs_Array_Complex)
321329
3. [ISR_16_PWMs_Array_Simple](examples/SAMD21/ISR_16_PWMs_Array_Simple)
330+
4. [ISR_Changing_PWM](examples/SAMD21/ISR_Changing_PWM)
331+
5. [ISR_Modify_PWM](examples/SAMD21/ISR_Modify_PWM)
322332

323333
#### For SAMD51
324334

325335
1. [ISR_16_PWMs_Array](examples/SAMD51/ISR_16_PWMs_Array)
326336
2. [ISR_16_PWMs_Array_Complex](examples/SAMD51/ISR_16_PWMs_Array_Complex)
327-
3. [ISR_16_PWMs_Array_Simple](examples/SAMD51/ISR_16_PWMs_Array_Simple)
337+
3. [ISR_16_PWMs_Array_Simple](examples/SAMD51/ISR_16_PWMs_Array_Simple)
338+
4. [ISR_Changing_PWM](examples/SAMD51/ISR_Changing_PWM)
339+
5. [ISR_Modify_PWM](examples/SAMD51/ISR_Modify_PWM)
328340

329341

330342
---
@@ -468,12 +480,11 @@ uint32_t PWM_Period[] =
468480
111111L, 100000L, 66667L, 50000L, 40000L, 33333L, 25000L, 20000L
469481
};
470482
471-
472483
// You can assign any interval for any timer here, in Hz
473-
uint32_t PWM_Freq[] =
484+
double PWM_Freq[NUMBER_ISR_PWMS] =
474485
{
475-
1, 2, 3, 4, 5, 6, 7, 8,
476-
9, 10, 15, 20, 25, 30, 40, 50
486+
1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f, 8.0f,
487+
9.0f, 10.0f, 15.0f, 20.0f, 25.0f, 30.0f, 40.0f, 50.0f
477488
};
478489
479490
// You can assign any interval for any timer here, in milliseconds
@@ -906,12 +917,12 @@ void loop()
906917

907918
### 1. ISR_16_PWMs_Array_Complex on SAMD_NANO_33_IOT
908919

909-
The following is the sample terminal output when running example [ISR_16_PWMs_Array_Complex](examples/ISR_16_PWMs_Array_Complex) on SAMD_NANO_33_IOT to demonstrate how to use multiple PWM channels with complex callback functions, the accuracy of ISR Hardware PWM-channels, **especially when system is very busy**. The ISR PWM-channels is **running exactly according to corresponding programmed periods and duty-cycles**
920+
The following is the sample terminal output when running example [ISR_16_PWMs_Array_Complex](examples/SAMD21/ISR_16_PWMs_Array_Complex) on SAMD_NANO_33_IOT to demonstrate how to use multiple PWM channels with complex callback functions, the accuracy of ISR Hardware PWM-channels, **especially when system is very busy**. The ISR PWM-channels is **running exactly according to corresponding programmed periods and duty-cycles**
910921

911922

912923
```
913924
Starting ISR_16_PWMs_Array_Complex on SAMD_NANO_33_IOT
914-
SAMD_Slow_PWM v1.0.0
925+
SAMD_Slow_PWM v1.1.0
915926
[PWM] _period = 20 , frequency = 50000.00
916927
[PWM] SAMDTimerInterrupt: F_CPU (MHz) = 48 , TIMER_HZ = 48
917928
[PWM] TC3_Timer::startTimer _Timer = 0x 42002c00 , TC3 = 0x 42002c00
@@ -959,12 +970,12 @@ PWM Channel : 7, programmed Period (us): 20000, actual : 20006, programmed DutyC
959970

960971
### 2. ISR_16_PWMs_Array_Complex on ITSYBITSY_M4
961972

962-
The following is the sample terminal output when running example [ISR_16_PWMs_Array_Complex](examples/ISR_16_PWMs_Array_Complex) on ITSYBITSY_M4 to demonstrate how to use multiple PWM channels with complex callback functions, the accuracy of ISR Hardware PWM-channels, **especially when system is very busy**. The ISR PWM-channels is **running exactly according to corresponding programmed periods and duty-cycles**
973+
The following is the sample terminal output when running example [ISR_16_PWMs_Array_Complex](examples/SAMD51/ISR_16_PWMs_Array_Complex) on ITSYBITSY_M4 to demonstrate how to use multiple PWM channels with complex callback functions, the accuracy of ISR Hardware PWM-channels, **especially when system is very busy**. The ISR PWM-channels is **running exactly according to corresponding programmed periods and duty-cycles**
963974

964975

965976
```
966977
Starting ISR_16_PWMs_Array_Complex on ITSYBITSY_M4
967-
SAMD_Slow_PWM v1.0.0
978+
SAMD_Slow_PWM v1.1.0
968979
[PWM] SAMDTimerInterrupt: F_CPU (MHz) = 120 , TIMER_HZ = 48
969980
[PWM] TC_Timer::startTimer _Timer = 0x 4101c000 , TC3 = 0x 4101c000
970981
[PWM] SAMD51 TC3 period = 20 , _prescaler = 1
@@ -1027,12 +1038,12 @@ PWM Channel : 15, programmed Period (us): 20000, actual : 19989, programmed Duty
10271038

10281039
### 3. ISR_16_PWMs_Array_Complex on SEEED_XIAO_M0
10291040

1030-
The following is the sample terminal output when running example [ISR_16_PWMs_Array_Complex](examples/ISR_16_PWMs_Array_Complex) on SEEED_XIAO_M0 to demonstrate how to use multiple PWM channels with complex callback functions, the accuracy of ISR Hardware PWM-channels, **especially when system is very busy**. The ISR PWM-channels is **running exactly according to corresponding programmed periods and duty-cycles**
1041+
The following is the sample terminal output when running example [ISR_16_PWMs_Array_Complex](examples/SAMD21/ISR_16_PWMs_Array_Complex) on SEEED_XIAO_M0 to demonstrate how to use multiple PWM channels with complex callback functions, the accuracy of ISR Hardware PWM-channels, **especially when system is very busy**. The ISR PWM-channels is **running exactly according to corresponding programmed periods and duty-cycles**
10311042

10321043

10331044
```
10341045
Starting ISR_16_PWMs_Array_Complex on SEEED_XIAO_M0
1035-
SAMD_Slow_PWM v1.0.0
1046+
SAMD_Slow_PWM v1.1.0
10361047
[PWM] _period = 20 , frequency = 50000.00
10371048
[PWM] SAMDTimerInterrupt: F_CPU (MHz) = 48 , TIMER_HZ = 48
10381049
[PWM] TC3_Timer::startTimer _Timer = 0x 42002c00 , TC3 = 0x 42002c00
@@ -1067,6 +1078,103 @@ PWM Channel : 6, programmed Period (us): 25000, actual : 24994, programmed DutyC
10671078
PWM Channel : 7, programmed Period (us): 20000, actual : 20000, programmed DutyCycle : 70, actual : 70.00
10681079
```
10691080

1081+
---
1082+
1083+
### 4. ISR_Modify_PWM on SAMD_NANO_33_IOT
1084+
1085+
The following is the sample terminal output when running example [ISR_Modify_PWM](examples/SAMD21/ISR_Modify_PWM) on **SAMD_NANO_33_IOT** to demonstrate how to modify PWM settings on-the-fly without deleting the PWM channel
1086+
1087+
```
1088+
Starting ISR_Modify_PWM on SAMD_NANO_33_IOT
1089+
SAMD_Slow_PWM v1.1.0
1090+
[PWM] _period = 20 , frequency = 50000.00
1091+
[PWM] SAMDTimerInterrupt: F_CPU (MHz) = 48 , TIMER_HZ = 48
1092+
[PWM] TC3_Timer::startTimer _Timer = 0x 42002c00 , TC3 = 0x 42002c00
1093+
[PWM] SAMD21 TC3 period = 20 , _prescaler = 1
1094+
[PWM] _compareValue = 959
1095+
Starting ITimer OK, micros() = 2821686
1096+
Using PWM Freq = 1.00, PWM DutyCycle = 10
1097+
Channel : 0 Period : 1000000 OnTime : 100000 Start_Time : 2822762
1098+
Channel : 0 Period : 500000 OnTime : 450000 Start_Time : 12824098
1099+
Channel : 0 Period : 1000000 OnTime : 100000 Start_Time : 22825080
1100+
Channel : 0 Period : 500000 OnTime : 450000 Start_Time : 32826081
1101+
```
1102+
1103+
---
1104+
1105+
### 5. ISR_Changing_PWM on SAMD_NANO_33_IOT
1106+
1107+
The following is the sample terminal output when running example [ISR_Changing_PWM](examples/SAMD21/ISR_Changing_PWM) on **SAMD_NANO_33_IOT** to demonstrate how to modify PWM settings on-the-fly by deleting the PWM channel and reinit the PWM channel
1108+
1109+
```
1110+
Starting ISR_Changing_PWM on SAMD_NANO_33_IOT
1111+
SAMD_Slow_PWM v1.1.0
1112+
[PWM] _period = 20 , frequency = 50000.00
1113+
[PWM] SAMDTimerInterrupt: F_CPU (MHz) = 48 , TIMER_HZ = 48
1114+
[PWM] TC3_Timer::startTimer _Timer = 0x 42002c00 , TC3 = 0x 42002c00
1115+
[PWM] SAMD21 TC3 period = 20 , _prescaler = 1
1116+
[PWM] _compareValue = 959
1117+
Starting ITimer OK, micros() = 2921757
1118+
Using PWM Freq = 1.00, PWM DutyCycle = 50
1119+
Channel : 0 Period : 1000000 OnTime : 500000 Start_Time : 2922855
1120+
Using PWM Freq = 2.00, PWM DutyCycle = 90
1121+
Channel : 0 Period : 500000 OnTime : 450000 Start_Time : 12924175
1122+
Using PWM Freq = 1.00, PWM DutyCycle = 50
1123+
Channel : 0 Period : 1000000 OnTime : 500000 Start_Time : 22925508
1124+
Using PWM Freq = 2.00, PWM DutyCycle = 90
1125+
Channel : 0 Period : 500000 OnTime : 450000 Start_Time : 32926654
1126+
```
1127+
1128+
---
1129+
1130+
### 6. ISR_Modify_PWM on ITSYBITSY_M4
1131+
1132+
The following is the sample terminal output when running example [ISR_Modify_PWM](examples/SAMD51/ISR_Modify_PWM) on **ITSYBITSY_M4** to demonstrate how to modify PWM settings on-the-fly without deleting the PWM channel
1133+
1134+
```
1135+
Starting ISR_Modify_PWM on ITSYBITSY_M4
1136+
SAMD_Slow_PWM v1.1.0
1137+
[PWM] SAMDTimerInterrupt: F_CPU (MHz) = 120 , TIMER_HZ = 48
1138+
[PWM] TC_Timer::startTimer _Timer = 0x 4101c000 , TC3 = 0x 4101c000
1139+
[PWM] SAMD51 TC3 period = 20 , _prescaler = 1
1140+
[PWM] _compareValue = 959
1141+
Starting ITimer OK, micros() = 3821127
1142+
Using PWM Freq = 1.00, PWM DutyCycle = 10
1143+
Channel : 0 Period : 1000000 OnTime : 100000 Start_Time : 3821615
1144+
Channel : 0 Period : 500000 OnTime : 450000 Start_Time : 13823005
1145+
Channel : 0 Period : 1000000 OnTime : 100000 Start_Time : 23824004
1146+
Channel : 0 Period : 500000 OnTime : 450000 Start_Time : 33825004
1147+
Channel : 0 Period : 1000000 OnTime : 100000 Start_Time : 43826004
1148+
Channel : 0 Period : 500000 OnTime : 450000 Start_Time : 53827004
1149+
Channel : 0 Period : 1000000 OnTime : 100000 Start_Time : 63828004
1150+
Channel : 0 Period : 500000 OnTime : 450000 Start_Time : 73829003
1151+
Channel : 0 Period : 1000000 OnTime : 100000 Start_Time : 83830004
1152+
```
1153+
1154+
---
1155+
1156+
### 7. ISR_Changing_PWM on ITSYBITSY_M4
1157+
1158+
The following is the sample terminal output when running example [ISR_Changing_PWM](examples/SAMD51/ISR_Changing_PWM) on **ITSYBITSY_M4** to demonstrate how to modify PWM settings on-the-fly by deleting the PWM channel and reinit the PWM channel
1159+
1160+
```
1161+
Starting ISR_Changing_PWM on ITSYBITSY_M4
1162+
SAMD_Slow_PWM v1.1.0
1163+
[PWM] SAMDTimerInterrupt: F_CPU (MHz) = 120 , TIMER_HZ = 48
1164+
[PWM] TC_Timer::startTimer _Timer = 0x 4101c000 , TC3 = 0x 4101c000
1165+
[PWM] SAMD51 TC3 period = 20 , _prescaler = 1
1166+
[PWM] _compareValue = 959
1167+
Starting ITimer OK, micros() = 2721076
1168+
Using PWM Freq = 1.00, PWM DutyCycle = 50
1169+
Channel : 0 Period : 1000000 OnTime : 500000 Start_Time : 2721574
1170+
Using PWM Freq = 2.00, PWM DutyCycle = 90
1171+
Channel : 0 Period : 500000 OnTime : 450000 Start_Time : 12722174
1172+
Using PWM Freq = 1.00, PWM DutyCycle = 50
1173+
Channel : 0 Period : 1000000 OnTime : 500000 Start_Time : 22722759
1174+
Using PWM Freq = 2.00, PWM DutyCycle = 90
1175+
Channel : 0 Period : 500000 OnTime : 450000 Start_Time : 32723417
1176+
```
1177+
10701178
---
10711179
---
10721180

@@ -1110,6 +1218,7 @@ Submit issues to: [SAMD_Slow_PWM issues](https://github.com/khoih-prog/SAMD_Slow
11101218

11111219
1. Basic hardware multi-channel PWM for **SAMD21/SAMD51 boards** such as NANO_33_IOT, ITSYBITSY_M4, SEEED_XIAO_M0, SparkFun_SAMD51_Thing_Plus, etc. using Arduino, Adafruit or Sparkfun core
11121220
2. Add Table of Contents
1221+
3. Add functions to modify PWM settings on-the-fly
11131222

11141223
---
11151224
---

changelog.md

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

1414
* [Changelog](#changelog)
15+
* [Releases v1.1.0](#releases-v110)
1516
* [Initial Releases v1.0.0](#Initial-Releases-v100)
1617

1718
---
1819
---
1920

2021
## Changelog
2122

23+
### Releases v1.1.0
24+
25+
1. Add functions to modify PWM settings on-the-fly
26+
2. Add example to demo how to modify PWM settings on-the-fly
27+
2228
### Initial Releases v1.0.0
2329

2430
1. Initial coding to support **SAMD21/SAMD51 boards** such as NANO_33_IOT, ITSYBITSY_M4, SEEED_XIAO_M0, SparkFun_SAMD51_Thing_Plus, etc. using Arduino, Adafruit or Sparkfun core

examples/SAMD21/ISR_16_PWMs_Array/ISR_16_PWMs_Array.ino

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,6 @@
1111
The accuracy is nearly perfect compared to software timers. The most important feature is they're ISR-based timers
1212
Therefore, their executions are not blocked by bad-behaving functions / tasks.
1313
This important feature is absolutely necessary for mission-critical tasks.
14-
15-
Version: 1.0.0
16-
17-
Version Modified By Date Comments
18-
------- ----------- ---------- -----------
19-
1.0.0 K.Hoang 01/10/2021 Initial coding for SAMD21/SAMD51 boards
2014
*****************************************************************************************************************************/
2115

2216
#if !( defined(ARDUINO_SAMD_ZERO) || defined(ARDUINO_SAMD_MKR1000) || defined(ARDUINO_SAMD_MKRWIFI1010) \
@@ -94,11 +88,10 @@ uint32_t PWM_Period[] =
9488
1000000L, 500000L, 66667L, 50000L, 40000L, 33333L, 25000L, 20000L
9589
};
9690

97-
9891
// You can assign any interval for any timer here, in Hz
99-
uint32_t PWM_Freq[] =
92+
double PWM_Freq[NUMBER_ISR_PWMS] =
10093
{
101-
1, 2, 15, 20, 25, 30, 40, 50
94+
1.0f, 2.0f, 15.0f, 20.0f, 25.0f, 30.0f, 40.0f, 50.0f,
10295
};
10396

10497
// You can assign any interval for any timer here, in milliseconds

examples/SAMD21/ISR_16_PWMs_Array_Complex/ISR_16_PWMs_Array_Complex.ino

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,6 @@
1111
The accuracy is nearly perfect compared to software timers. The most important feature is they're ISR-based timers
1212
Therefore, their executions are not blocked by bad-behaving functions / tasks.
1313
This important feature is absolutely necessary for mission-critical tasks.
14-
15-
Version: 1.0.0
16-
17-
Version Modified By Date Comments
18-
------- ----------- ---------- -----------
19-
1.0.0 K.Hoang 01/10/2021 Initial coding for SAMD21/SAMD51 boards
2014
*****************************************************************************************************************************/
2115

2216
#if !( defined(ARDUINO_SAMD_ZERO) || defined(ARDUINO_SAMD_MKR1000) || defined(ARDUINO_SAMD_MKRWIFI1010) \
@@ -149,11 +143,10 @@ uint32_t PWM_Period[] =
149143
1000000L, 500000L, 66667L, 50000L, 40000L, 33333L, 25000L, 20000L
150144
};
151145

152-
153146
// You can assign any interval for any timer here, in Hz
154-
uint32_t PWM_Freq[] =
147+
double PWM_Freq[NUMBER_ISR_PWMS] =
155148
{
156-
1, 2, 15, 20, 25, 30, 40, 50
149+
1.0f, 2.0f, 15.0f, 20.0f, 25.0f, 30.0f, 40.0f, 50.0f,
157150
};
158151

159152
// You can assign any interval for any timer here, in milliseconds

examples/SAMD21/ISR_16_PWMs_Array_Simple/ISR_16_PWMs_Array_Simple.ino

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,6 @@
1111
The accuracy is nearly perfect compared to software timers. The most important feature is they're ISR-based timers
1212
Therefore, their executions are not blocked by bad-behaving functions / tasks.
1313
This important feature is absolutely necessary for mission-critical tasks.
14-
15-
Version: 1.0.0
16-
17-
Version Modified By Date Comments
18-
------- ----------- ---------- -----------
19-
1.0.0 K.Hoang 01/10/2021 Initial coding for SAMD21/SAMD51 boards
2014
*****************************************************************************************************************************/
2115

2216
#if !( defined(ARDUINO_SAMD_ZERO) || defined(ARDUINO_SAMD_MKR1000) || defined(ARDUINO_SAMD_MKRWIFI1010) \
@@ -103,11 +97,10 @@ uint32_t PWM_Period[] =
10397
1000000L, 500000L, 66667L, 50000L, 40000L, 33333L, 25000L, 20000L
10498
};
10599

106-
107100
// You can assign any interval for any timer here, in Hz
108-
uint32_t PWM_Freq[] =
101+
double PWM_Freq[NUMBER_ISR_PWMS] =
109102
{
110-
1, 2, 15, 20, 25, 30, 40, 50
103+
1.0f, 2.0f, 15.0f, 20.0f, 25.0f, 30.0f, 40.0f, 50.0f,
111104
};
112105

113106
// You can assign any interval for any timer here, in milliseconds

0 commit comments

Comments
 (0)