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

Commit e52cd46

Browse files
authored
v1.2.3 to fix DutyCycle bug, etc.
### Releases v1.2.3 1. Fix `DutyCycle` bug. Check [float precisison of DutyCycle only sometimes working #3](khoih-prog/SAMD_Slow_PWM#3) 2. Fix `New Period` display bug. Check [random dropouts #4](khoih-prog/SAMD_Slow_PWM#4) 3. Update examples
1 parent 42d95b1 commit e52cd46

File tree

6 files changed

+53
-25
lines changed

6 files changed

+53
-25
lines changed

examples/ISR_8_PWMs_Array/ISR_8_PWMs_Array.ino

+9-3
Original file line numberDiff line numberDiff line change
@@ -26,17 +26,23 @@
2626
defined(ARDUINO_AVR_METRO) || defined(ARDUINO_AVR_PROTRINKET5) || defined(ARDUINO_AVR_PROTRINKET3) || defined(ARDUINO_AVR_PROTRINKET5FTDI) || \
2727
defined(ARDUINO_AVR_PROTRINKET3FTDI) )
2828
#define USE_TIMER_1 true
29-
#warning Using Timer1
3029
#else
3130
#define USE_TIMER_3 true
32-
#warning Using Timer3
3331
#endif
3432

35-
// These define's must be placed at the beginning before #include "ESP32_PWM.h"
33+
// These define's must be placed at the beginning before #include "AVR_Slow_PWM.h"
3634
// _PWM_LOGLEVEL_ from 0 to 4
3735
// Don't define _PWM_LOGLEVEL_ > 0. Only for special ISR debugging only. Can hang the system.
3836
#define _PWM_LOGLEVEL_ 3
3937

38+
#if (_PWM_LOGLEVEL_ > 3)
39+
#if USE_TIMER_1
40+
#warning Using Timer1
41+
#elif USE_TIMER_1
42+
#warning Using Timer3
43+
#endif
44+
#endif
45+
4046
#define USING_MICROS_RESOLUTION true //false
4147

4248
// Default is true, uncomment to false

examples/ISR_8_PWMs_Array_Complex/ISR_8_PWMs_Array_Complex.ino

+9-3
Original file line numberDiff line numberDiff line change
@@ -26,17 +26,23 @@
2626
defined(ARDUINO_AVR_METRO) || defined(ARDUINO_AVR_PROTRINKET5) || defined(ARDUINO_AVR_PROTRINKET3) || defined(ARDUINO_AVR_PROTRINKET5FTDI) || \
2727
defined(ARDUINO_AVR_PROTRINKET3FTDI) )
2828
#define USE_TIMER_1 true
29-
#warning Using Timer1
3029
#else
3130
#define USE_TIMER_3 true
32-
#warning Using Timer3
3331
#endif
3432

35-
// These define's must be placed at the beginning before #include "ESP32_PWM.h"
33+
// These define's must be placed at the beginning before #include "AVR_Slow_PWM.h"
3634
// _PWM_LOGLEVEL_ from 0 to 4
3735
// Don't define _PWM_LOGLEVEL_ > 0. Only for special ISR debugging only. Can hang the system.
3836
#define _PWM_LOGLEVEL_ 3
3937

38+
#if (_PWM_LOGLEVEL_ > 3)
39+
#if USE_TIMER_1
40+
#warning Using Timer1
41+
#elif USE_TIMER_1
42+
#warning Using Timer3
43+
#endif
44+
#endif
45+
4046
#define USING_MICROS_RESOLUTION true //false
4147

4248
// Default is true, uncomment to false

examples/ISR_8_PWMs_Array_Simple/ISR_8_PWMs_Array_Simple.ino

+9-3
Original file line numberDiff line numberDiff line change
@@ -26,17 +26,23 @@
2626
defined(ARDUINO_AVR_METRO) || defined(ARDUINO_AVR_PROTRINKET5) || defined(ARDUINO_AVR_PROTRINKET3) || defined(ARDUINO_AVR_PROTRINKET5FTDI) || \
2727
defined(ARDUINO_AVR_PROTRINKET3FTDI) )
2828
#define USE_TIMER_1 true
29-
#warning Using Timer1
3029
#else
3130
#define USE_TIMER_3 true
32-
#warning Using Timer3
3331
#endif
3432

35-
// These define's must be placed at the beginning before #include "ESP32_PWM.h"
33+
// These define's must be placed at the beginning before #include "AVR_Slow_PWM.h"
3634
// _PWM_LOGLEVEL_ from 0 to 4
3735
// Don't define _PWM_LOGLEVEL_ > 0. Only for special ISR debugging only. Can hang the system.
3836
#define _PWM_LOGLEVEL_ 3
3937

38+
#if (_PWM_LOGLEVEL_ > 3)
39+
#if USE_TIMER_1
40+
#warning Using Timer1
41+
#elif USE_TIMER_1
42+
#warning Using Timer3
43+
#endif
44+
#endif
45+
4046
#define USING_MICROS_RESOLUTION true //false
4147

4248
// Default is true, uncomment to false

examples/ISR_Changing_PWM/ISR_Changing_PWM.ino

+9-3
Original file line numberDiff line numberDiff line change
@@ -26,17 +26,23 @@
2626
defined(ARDUINO_AVR_METRO) || defined(ARDUINO_AVR_PROTRINKET5) || defined(ARDUINO_AVR_PROTRINKET3) || defined(ARDUINO_AVR_PROTRINKET5FTDI) || \
2727
defined(ARDUINO_AVR_PROTRINKET3FTDI) )
2828
#define USE_TIMER_1 true
29-
#warning Using Timer1
3029
#else
3130
#define USE_TIMER_3 true
32-
#warning Using Timer3
3331
#endif
3432

35-
// These define's must be placed at the beginning before #include "ESP32_PWM.h"
33+
// These define's must be placed at the beginning before #include "AVR_Slow_PWM.h"
3634
// _PWM_LOGLEVEL_ from 0 to 4
3735
// Don't define _PWM_LOGLEVEL_ > 0. Only for special ISR debugging only. Can hang the system.
3836
#define _PWM_LOGLEVEL_ 3
3937

38+
#if (_PWM_LOGLEVEL_ > 3)
39+
#if USE_TIMER_1
40+
#warning Using Timer1
41+
#elif USE_TIMER_1
42+
#warning Using Timer3
43+
#endif
44+
#endif
45+
4046
#define USING_MICROS_RESOLUTION true //false
4147

4248
// Default is true, uncomment to false

examples/ISR_Modify_PWM/ISR_Modify_PWM.ino

+15-9
Original file line numberDiff line numberDiff line change
@@ -26,17 +26,23 @@
2626
defined(ARDUINO_AVR_METRO) || defined(ARDUINO_AVR_PROTRINKET5) || defined(ARDUINO_AVR_PROTRINKET3) || defined(ARDUINO_AVR_PROTRINKET5FTDI) || \
2727
defined(ARDUINO_AVR_PROTRINKET3FTDI) )
2828
#define USE_TIMER_1 true
29-
#warning Using Timer1
3029
#else
3130
#define USE_TIMER_3 true
32-
#warning Using Timer3
3331
#endif
3432

35-
// These define's must be placed at the beginning before #include "ESP32_PWM.h"
33+
// These define's must be placed at the beginning before #include "AVR_Slow_PWM.h"
3634
// _PWM_LOGLEVEL_ from 0 to 4
3735
// Don't define _PWM_LOGLEVEL_ > 0. Only for special ISR debugging only. Can hang the system.
3836
#define _PWM_LOGLEVEL_ 3
3937

38+
#if (_PWM_LOGLEVEL_ > 3)
39+
#if USE_TIMER_1
40+
#warning Using Timer1
41+
#elif USE_TIMER_1
42+
#warning Using Timer3
43+
#endif
44+
#endif
45+
4046
#define USING_MICROS_RESOLUTION true //false
4147

4248
// Default is true, uncomment to false
@@ -86,19 +92,19 @@ void TimerHandler()
8692
uint32_t PWM_Pin = LED_BUILTIN;
8793

8894
// You can assign any interval for any timer here, in Hz
89-
float PWM_Freq1 = 1.0f;
95+
float PWM_Freq1 = 200.0f; //1.0f;
9096
// You can assign any interval for any timer here, in Hz
91-
float PWM_Freq2 = 2.0f;
97+
float PWM_Freq2 = 100.0f; //2.0f;
9298

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

98104
// You can assign any duty_cycle for any PWM here, from 0-100
99-
float PWM_DutyCycle1 = 50.0;
105+
float PWM_DutyCycle1 = 1.0f; //50.0f;
100106
// You can assign any duty_cycle for any PWM here, from 0-100
101-
float PWM_DutyCycle2 = 90.0;
107+
float PWM_DutyCycle2 = 5.55f; //90.0f;
102108

103109
// Channel number used to identify associated channel
104110
int channelNum;
@@ -207,8 +213,8 @@ void changePWM()
207213
{
208214
static uint8_t count = 1;
209215

210-
double PWM_Freq;
211-
uint32_t PWM_DutyCycle;
216+
float PWM_Freq;
217+
float PWM_DutyCycle;
212218

213219
if (count++ % 2)
214220
{

examples/multiFileProject/multiFileProject.ino

+2-4
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,12 @@
1717
defined(ARDUINO_AVR_METRO) || defined(ARDUINO_AVR_PROTRINKET5) || defined(ARDUINO_AVR_PROTRINKET3) || defined(ARDUINO_AVR_PROTRINKET5FTDI) || \
1818
defined(ARDUINO_AVR_PROTRINKET3FTDI) )
1919
#define USE_TIMER_1 true
20-
#warning Using Timer1
2120
#else
2221
#define USE_TIMER_3 true
23-
#warning Using Timer3
2422
#endif
2523

26-
#define AVR_SLOW_PWM_VERSION_MIN_TARGET F("AVR_Slow_PWM v1.2.2")
27-
#define AVR_SLOW_PWM_VERSION_MIN 1002002
24+
#define AVR_SLOW_PWM_VERSION_MIN_TARGET F("AVR_Slow_PWM v1.2.3")
25+
#define AVR_SLOW_PWM_VERSION_MIN 1002003
2826

2927
#include "multiFileProject.h"
3028

0 commit comments

Comments
 (0)