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

Commit

Permalink
v1.2.0 to fix multiple-definitions linker error
Browse files Browse the repository at this point in the history
### Releases v1.2.0

1. Fix `multiple-definitions` linker error. Drop `src_cpp` and `src_h` directories
2. Add example [multiFileProject](examples/multiFileProject) to demo for multiple-file project
3. Improve accuracy by using `double`, instead of `uint32_t` for `dutycycle`, `period`
4. Optimize library code by using `reference-passing` instead of `value-passing`
5. Fix reattachInterrupt() bug. Check [bugfix: reattachInterrupt() pass wrong frequency value to setFrequency() #19](khoih-prog/ESP8266TimerInterrupt#19)
6. Update examples accordingly
  • Loading branch information
khoih-prog committed Jan 30, 2022
1 parent 7e4c9fd commit 655e979
Show file tree
Hide file tree
Showing 20 changed files with 1,242 additions and 985 deletions.
10 changes: 5 additions & 5 deletions CONTRIBUTING.md
Expand Up @@ -14,8 +14,8 @@ If you don't find anything, please [open a new issue](https://github.com/khoih-p

Please ensure to specify the following:

* Arduino IDE version (e.g. 1.8.16) or Platform.io version
* `STM32` Core Version (e.g. STM32 core v2.1.0)
* Arduino IDE version (e.g. 1.8.19) or Platform.io version
* `STM32` Core Version (e.g. STM32 core v2.2.0)
* Board type and relevant info
* Contextual information (e.g. what you were trying to achieve)
* Simplest possible steps to reproduce
Expand All @@ -27,11 +27,11 @@ Please ensure to specify the following:
### Example

```
Arduino IDE version: 1.8.16
STM32 Core Version 2.1.0
Arduino IDE version: 1.8.19
STM32 Core Version 2.2.0
Nucleo-144 STM32H7 NUCLEO_H743ZI2
OS: Ubuntu 20.04 LTS
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
Linux xy-Inspiron-3593 5.4.0-96-generic #109-Ubuntu SMP Wed Jan 12 16:49:16 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux
Context:
I encountered a crash while using TimerInterrupt.
Expand Down
526 changes: 286 additions & 240 deletions README.md

Large diffs are not rendered by default.

10 changes: 10 additions & 0 deletions changelog.md
Expand Up @@ -12,6 +12,7 @@
## Table of Contents

* [Changelog](#changelog)
* [Releases v1.2.0](#releases-v120)
* [Releases v1.1.0](#releases-v110)
* [Initial Releases v1.0.0](#Initial-Releases-v100)

Expand All @@ -20,6 +21,15 @@

## Changelog

### Releases v1.2.0

1. Fix `multiple-definitions` linker error. Drop `src_cpp` and `src_h` directories
2. Add example [multiFileProject](examples/multiFileProject) to demo for multiple-file project
3. Improve accuracy by using `double`, instead of `uint32_t` for `dutycycle`, `period`
4. Optimize library code by using `reference-passing` instead of `value-passing`
5. Fix reattachInterrupt() bug. Check [bugfix: reattachInterrupt() pass wrong frequency value to setFrequency() #19](https://github.com/khoih-prog/ESP8266TimerInterrupt/pull/19)
6. Update examples accordingly

### Releases v1.1.0

1. Add functions to modify PWM settings on-the-fly
Expand Down
22 changes: 11 additions & 11 deletions examples/ISR_16_PWMs_Array/ISR_16_PWMs_Array.ino
Expand Up @@ -28,6 +28,7 @@

#define MAX_STM32_PWM_FREQ 1000

// To be included only in main(), .ino with setup() to avoid `Multiple Definitions` Linker Error
#include "STM32_Slow_PWM.h"

#define LED_OFF LOW
Expand Down Expand Up @@ -96,31 +97,30 @@ void TimerHandler()
//////////////////////////////////////////////////////

// You can assign pins here. Be carefull to select good pin to use or crash, e.g pin 6-11
uint32_t PWM_Pin[NUMBER_ISR_PWMS] =
uint32_t PWM_Pin[] =
{
LED_BUILTIN, LED_BLUE, LED_RED, PIN_D0, PIN_D1, PIN_D2, PIN_D3, PIN_D4,
PIN_D5, PIN_D6, PIN_D7, PIN_D8, PIN_D9, PIN_D10, PIN_D11, PIN_D12
LED_BUILTIN, LED_BLUE, LED_RED, PIN_D0, PIN_D1, PIN_D2, PIN_D3, PIN_D4,
PIN_D5, PIN_D6, PIN_D7, PIN_D8, PIN_D9, PIN_D10, PIN_D11, PIN_D12
};

// You can assign any interval for any timer here, in microseconds
uint32_t PWM_Period[NUMBER_ISR_PWMS] =
double PWM_Period[] =
{
1000000L, 500000L, 333333L, 250000L, 200000L, 166667L, 142857L, 125000L,
111111L, 100000L, 66667L, 50000L, 40000L, 33333L, 25000L, 20000L
};
1000000.0, 500000.0, 333333.333, 250000.0, 200000.0, 166666.667, 142857.143, 125000.0,
111111.111, 100000.0, 66666.667, 50000.0, 40000.0, 33333.333, 25000.0, 20000.0};

// You can assign any interval for any timer here, in Hz
double PWM_Freq[NUMBER_ISR_PWMS] =
double PWM_Freq[] =
{
1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f, 8.0f,
9.0f, 10.0f, 15.0f, 20.0f, 25.0f, 30.0f, 40.0f, 50.0f
};

// You can assign any interval for any timer here, in milliseconds
uint32_t PWM_DutyCycle[NUMBER_ISR_PWMS] =
double PWM_DutyCycle[] =
{
5, 10, 20, 30, 40, 45, 50, 55,
60, 65, 70, 75, 80, 85, 90, 95
5.0, 10.0, 20.0, 30.0, 40.0, 45.0, 50.0, 55.0,
60.0, 65.0, 70.0, 75.0, 80.0, 85.0, 90.0, 95.0
};

typedef void (*irqCallback) ();
Expand Down
118 changes: 59 additions & 59 deletions examples/ISR_16_PWMs_Array_Complex/ISR_16_PWMs_Array_Complex.ino
Expand Up @@ -28,6 +28,7 @@

#define MAX_STM32_PWM_FREQ 1000

// To be included only in main(), .ino with setup() to avoid `Multiple Definitions` Linker Error
#include "STM32_Slow_PWM.h"

#define boolean bool
Expand Down Expand Up @@ -112,12 +113,12 @@ typedef struct
irqCallback irqCallbackStopFunc;

#if USING_PWM_FREQUENCY
uint32_t PWM_Freq;
double PWM_Freq;
#else
uint32_t PWM_Period;
double PWM_Period;
#endif

uint32_t PWM_DutyCycle;
double PWM_DutyCycle;

uint64_t deltaMicrosStart;
uint64_t previousMicrosStart;
Expand All @@ -137,38 +138,37 @@ void doingSomethingStop(int index);

#else // #if USE_COMPLEX_STRUCT

volatile unsigned long deltaMicrosStart [NUMBER_ISR_PWMS] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
volatile unsigned long previousMicrosStart [NUMBER_ISR_PWMS] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
volatile unsigned long deltaMicrosStart [] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
volatile unsigned long previousMicrosStart [] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };

volatile unsigned long deltaMicrosStop [NUMBER_ISR_PWMS] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
volatile unsigned long previousMicrosStop [NUMBER_ISR_PWMS] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
volatile unsigned long deltaMicrosStop [] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
volatile unsigned long previousMicrosStop [] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };

// You can assign pins here. Be carefull to select good pin to use or crash, e.g pin 6-11
uint32_t PWM_Pin[NUMBER_ISR_PWMS] =
uint32_t PWM_Pin[] =
{
LED_BUILTIN, LED_BLUE, LED_RED, PIN_D0, PIN_D1, PIN_D2, PIN_D3, PIN_D4,
PIN_D5, PIN_D6, PIN_D7, PIN_D8, PIN_D9, PIN_D10, PIN_D11, PIN_D12
LED_BUILTIN, LED_BLUE, LED_RED, PIN_D0, PIN_D1, PIN_D2, PIN_D3, PIN_D4,
PIN_D5, PIN_D6, PIN_D7, PIN_D8, PIN_D9, PIN_D10, PIN_D11, PIN_D12
};

// You can assign any interval for any timer here, in microseconds
uint32_t PWM_Period[NUMBER_ISR_PWMS] =
double PWM_Period[] =
{
1000000L, 500000L, 333333L, 250000L, 200000L, 166667L, 142857L, 125000L,
111111L, 100000L, 66667L, 50000L, 40000L, 33333L, 25000L, 20000L
};
1000000.0, 500000.0, 333333.333, 250000.0, 200000.0, 166666.667, 142857.143, 125000.0,
111111.111, 100000.0, 66666.667, 50000.0, 40000.0, 33333.333, 25000.0, 20000.0};

// You can assign any interval for any timer here, in Hz
double PWM_Freq[NUMBER_ISR_PWMS] =
double PWM_Freq[] =
{
1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f, 8.0f,
9.0f, 10.0f, 15.0f, 20.0f, 25.0f, 30.0f, 40.0f, 50.0f
};

// You can assign any interval for any timer here, in milliseconds
uint32_t PWM_DutyCycle[NUMBER_ISR_PWMS] =
double PWM_DutyCycle[] =
{
5, 10, 20, 30, 40, 45, 50, 55,
60, 65, 70, 75, 80, 85, 90, 95
5.0, 10.0, 20.0, 30.0, 40.0, 45.0, 50.0, 55.0,
60.0, 65.0, 70.0, 75.0, 80.0, 85.0, 90.0, 95.0
};

void doingSomethingStart(int index)
Expand Down Expand Up @@ -362,48 +362,48 @@ void doingSomethingStop15()

#if USING_PWM_FREQUENCY

ISR_PWM_Data curISR_PWM_Data[NUMBER_ISR_PWMS] =
ISR_PWM_Data curISR_PWM_Data[] =
{
// pin, irqCallbackStartFunc, irqCallbackStopFunc, PWM_Freq, PWM_DutyCycle, deltaMicrosStart, previousMicrosStart, deltaMicrosStop, previousMicrosStop
{ LED_BUILTIN, doingSomethingStart0, doingSomethingStop0, 1, 5, 0, 0, 0, 0 },
{ LED_BLUE, doingSomethingStart1, doingSomethingStop1, 2, 10, 0, 0, 0, 0 },
{ LED_RED, doingSomethingStart2, doingSomethingStop2, 3, 20, 0, 0, 0, 0 },
{ PIN_D0, doingSomethingStart3, doingSomethingStop3, 4, 30, 0, 0, 0, 0 },
{ PIN_D1, doingSomethingStart4, doingSomethingStop4, 5, 40, 0, 0, 0, 0 },
{ PIN_D2, doingSomethingStart5, doingSomethingStop5, 6, 45, 0, 0, 0, 0 },
{ PIN_D3, doingSomethingStart6, doingSomethingStop6, 7, 50, 0, 0, 0, 0 },
{ PIN_D4, doingSomethingStart7, doingSomethingStop7, 8, 55, 0, 0, 0, 0 },
{ PIN_D5, doingSomethingStart8, doingSomethingStop8, 9, 60, 0, 0, 0, 0 },
{ PIN_D6, doingSomethingStart9, doingSomethingStop9, 10, 65, 0, 0, 0, 0 },
{ PIN_D7, doingSomethingStart10, doingSomethingStop10, 15, 70, 0, 0, 0, 0 },
{ PIN_D8, doingSomethingStart11, doingSomethingStop11, 20, 75, 0, 0, 0, 0 },
{ PIN_D9, doingSomethingStart12, doingSomethingStop12, 25, 80, 0, 0, 0, 0 },
{ PIN_D10, doingSomethingStart13, doingSomethingStop13, 30, 85, 0, 0, 0, 0 },
{ PIN_D11, doingSomethingStart14, doingSomethingStop14, 40, 90, 0, 0, 0, 0 },
{ PIN_D12, doingSomethingStart15, doingSomethingStop15, 50, 95, 0, 0, 0, 0 }
{ LED_BUILTIN, doingSomethingStart0, doingSomethingStop0, 1.0, 5.0, 0, 0, 0, 0 },
{ LED_BLUE, doingSomethingStart1, doingSomethingStop1, 2.0, 10.0, 0, 0, 0, 0 },
{ LED_RED, doingSomethingStart2, doingSomethingStop2, 3.0, 20.0, 0, 0, 0, 0 },
{ PIN_D0, doingSomethingStart3, doingSomethingStop3, 4.0, 30.0, 0, 0, 0, 0 },
{ PIN_D1, doingSomethingStart4, doingSomethingStop4, 5.0, 40.0, 0, 0, 0, 0 },
{ PIN_D2, doingSomethingStart5, doingSomethingStop5, 6.0, 45.0, 0, 0, 0, 0 },
{ PIN_D3, doingSomethingStart6, doingSomethingStop6, 7.0, 50.0, 0, 0, 0, 0 },
{ PIN_D4, doingSomethingStart7, doingSomethingStop7, 8.0, 55.0, 0, 0, 0, 0 },
{ PIN_D5, doingSomethingStart8, doingSomethingStop8, 9.0, 60.0, 0, 0, 0, 0 },
{ PIN_D6, doingSomethingStart9, doingSomethingStop9, 10.0, 65.0, 0, 0, 0, 0 },
{ PIN_D7, doingSomethingStart10, doingSomethingStop10, 15.0, 70.0, 0, 0, 0, 0 },
{ PIN_D8, doingSomethingStart11, doingSomethingStop11, 20.0, 75.0, 0, 0, 0, 0 },
{ PIN_D9, doingSomethingStart12, doingSomethingStop12, 25.0, 80.0, 0, 0, 0, 0 },
{ PIN_D10, doingSomethingStart13, doingSomethingStop13, 30.0, 85.0, 0, 0, 0, 0 },
{ PIN_D11, doingSomethingStart14, doingSomethingStop14, 40.0, 90.0, 0, 0, 0, 0 },
{ PIN_D12, doingSomethingStart15, doingSomethingStop15, 50.0, 95.0, 0, 0, 0, 0 }
};

#else // #if USING_PWM_FREQUENCY

ISR_PWM_Data curISR_PWM_Data[NUMBER_ISR_PWMS] =
ISR_PWM_Data curISR_PWM_Data[] =
{
// pin, irqCallbackStartFunc, irqCallbackStopFunc, PWM_Period, PWM_DutyCycle, deltaMicrosStart, previousMicrosStart, deltaMicrosStop, previousMicrosStop
{ LED_BUILTIN, doingSomethingStart0, doingSomethingStop0, 1000000L, 5, 0, 0, 0, 0 },
{ LED_BLUE, doingSomethingStart1, doingSomethingStop1, 500000L, 10, 0, 0, 0, 0 },
{ LED_RED, doingSomethingStart2, doingSomethingStop2, 333333L, 20, 0, 0, 0, 0 },
{ PIN_D0, doingSomethingStart3, doingSomethingStop3, 250000L, 30, 0, 0, 0, 0 },
{ PIN_D1, doingSomethingStart4, doingSomethingStop4, 200000L, 40, 0, 0, 0, 0 },
{ PIN_D2, doingSomethingStart5, doingSomethingStop5, 166667L, 45, 0, 0, 0, 0 },
{ PIN_D3, doingSomethingStart6, doingSomethingStop6, 142857L, 50, 0, 0, 0, 0 },
{ PIN_D4, doingSomethingStart7, doingSomethingStop7, 125000L, 55, 0, 0, 0, 0 },
{ PIN_D5, doingSomethingStart8, doingSomethingStop8, 111111L, 60, 0, 0, 0, 0 },
{ PIN_D6, doingSomethingStart9, doingSomethingStop9, 100000L, 65, 0, 0, 0, 0 },
{ PIN_D7, doingSomethingStart10, doingSomethingStop10, 66667L, 70, 0, 0, 0, 0 },
{ PIN_D8, doingSomethingStart11, doingSomethingStop11, 50000L, 75, 0, 0, 0, 0 },
{ PIN_D9, doingSomethingStart12, doingSomethingStop12, 40000L, 80, 0, 0, 0, 0 },
{ PIN_D10, doingSomethingStart13, doingSomethingStop13, 33333L, 85, 0, 0, 0, 0 },
{ PIN_D11, doingSomethingStart14, doingSomethingStop14, 25000L, 90, 0, 0, 0, 0 },
{ PIN_D12, doingSomethingStart15, doingSomethingStop15, 20000L, 95, 0, 0, 0, 0 }
{ LED_BUILTIN, doingSomethingStart0, doingSomethingStop0, 1000000.0, 5.0, 0, 0, 0, 0 },
{ LED_BLUE, doingSomethingStart1, doingSomethingStop1, 500000.0, 10.0, 0, 0, 0, 0 },
{ LED_RED, doingSomethingStart2, doingSomethingStop2, 333333.0, 20.0, 0, 0, 0, 0 },
{ PIN_D0, doingSomethingStart3, doingSomethingStop3, 250000.0, 30.0, 0, 0, 0, 0 },
{ PIN_D1, doingSomethingStart4, doingSomethingStop4, 200000.0, 40.0, 0, 0, 0, 0 },
{ PIN_D2, doingSomethingStart5, doingSomethingStop5, 166667.0, 45.0, 0, 0, 0, 0 },
{ PIN_D3, doingSomethingStart6, doingSomethingStop6, 142857.0, 50.0, 0, 0, 0, 0 },
{ PIN_D4, doingSomethingStart7, doingSomethingStop7, 125000.0, 55.0, 0, 0, 0, 0 },
{ PIN_D5, doingSomethingStart8, doingSomethingStop8, 111111.0, 60.0, 0, 0, 0, 0 },
{ PIN_D6, doingSomethingStart9, doingSomethingStop9, 100000.0, 65.0, 0, 0, 0, 0 },
{ PIN_D7, doingSomethingStart10, doingSomethingStop10, 66667.0, 70.0, 0, 0, 0, 0 },
{ PIN_D8, doingSomethingStart11, doingSomethingStop11, 50000.0, 75.0, 0, 0, 0, 0 },
{ PIN_D9, doingSomethingStart12, doingSomethingStop12, 40000.0, 80.0, 0, 0, 0, 0 },
{ PIN_D10, doingSomethingStart13, doingSomethingStop13, 33333.0, 85.0.0, 0, 0, 0, 0 },
{ PIN_D11, doingSomethingStart14, doingSomethingStop14, 25000.0, 90.0, 0, 0, 0, 0 },
{ PIN_D12, doingSomethingStart15, doingSomethingStop15, 20000.0, 95.0, 0, 0, 0, 0 }
};

#endif // #if USING_PWM_FREQUENCY
Expand All @@ -428,15 +428,15 @@ void doingSomethingStop(int index)

#else // #if USE_COMPLEX_STRUCT

irqCallback irqCallbackStartFunc[NUMBER_ISR_PWMS] =
irqCallback irqCallbackStartFunc[] =
{
doingSomethingStart0, doingSomethingStart1, doingSomethingStart2, doingSomethingStart3,
doingSomethingStart4, doingSomethingStart5, doingSomethingStart6, doingSomethingStart7,
doingSomethingStart8, doingSomethingStart9, doingSomethingStart10, doingSomethingStart11,
doingSomethingStart12, doingSomethingStart13, doingSomethingStart14, doingSomethingStart15
};

irqCallback irqCallbackStopFunc[NUMBER_ISR_PWMS] =
irqCallback irqCallbackStopFunc[] =
{
doingSomethingStop0, doingSomethingStop1, doingSomethingStop2, doingSomethingStop3,
doingSomethingStop4, doingSomethingStop5, doingSomethingStop6, doingSomethingStop7,
Expand Down Expand Up @@ -471,15 +471,15 @@ void simpleTimerDoingSomething2s()
{
#if USE_COMPLEX_STRUCT
Serial.print(F("PWM Channel : ")); Serial.print(i);
Serial.print(F(", programmed Period (us): "));
Serial.print(F(", programmed Period (uS): "));

#if USING_PWM_FREQUENCY
Serial.print(1000000 / curISR_PWM_Data[i].PWM_Freq);
Serial.print(1000000.0 / curISR_PWM_Data[i].PWM_Freq);
#else
Serial.print(curISR_PWM_Data[i].PWM_Period);
#endif

Serial.print(F(", actual : ")); Serial.print(curISR_PWM_Data[i].deltaMicrosStart);
Serial.print(F(", actual (uS) : ")); Serial.print(curISR_PWM_Data[i].deltaMicrosStart);

Serial.print(F(", programmed DutyCycle : "));

Expand All @@ -497,8 +497,8 @@ void simpleTimerDoingSomething2s()
Serial.print(PWM_Period[i]);
#endif

Serial.print(F(", programmed Period (us): ")); Serial.print(PWM_Period[i]);
Serial.print(F(", actual : ")); Serial.print(deltaMicrosStart[i]);
Serial.print(F(", programmed Period (uS): ")); Serial.print(PWM_Period[i]);
Serial.print(F(", actual (uS): ")); Serial.print(deltaMicrosStart[i]);

Serial.print(F(", programmed DutyCycle : "));

Expand Down
23 changes: 11 additions & 12 deletions examples/ISR_16_PWMs_Array_Simple/ISR_16_PWMs_Array_Simple.ino
Expand Up @@ -28,6 +28,7 @@

#define MAX_STM32_PWM_FREQ 1000

// To be included only in main(), .ino with setup() to avoid `Multiple Definitions` Linker Error
#include "STM32_Slow_PWM.h"

#define LED_OFF LOW
Expand Down Expand Up @@ -96,35 +97,33 @@ void TimerHandler()
//////////////////////////////////////////////////////

// You can assign pins here. Be carefull to select good pin to use or crash, e.g pin 6-11
uint32_t PWM_Pin[NUMBER_ISR_PWMS] =
uint32_t PWM_Pin[] =
{
LED_BUILTIN, LED_BLUE, LED_RED, PIN_D0, PIN_D1, PIN_D2, PIN_D3, PIN_D4,
PIN_D5, PIN_D6, PIN_D7, PIN_D8, PIN_D9, PIN_D10, PIN_D11, PIN_D12
LED_BUILTIN, LED_BLUE, LED_RED, PIN_D0, PIN_D1, PIN_D2, PIN_D3, PIN_D4,
PIN_D5, PIN_D6, PIN_D7, PIN_D8, PIN_D9, PIN_D10, PIN_D11, PIN_D12
};

// You can assign any interval for any timer here, in microseconds
uint32_t PWM_Period[NUMBER_ISR_PWMS] =
double PWM_Period[] =
{
1000000L, 500000L, 333333L, 250000L, 200000L, 166667L, 142857L, 125000L,
111111L, 100000L, 66667L, 50000L, 40000L, 33333L, 25000L, 20000L
};
1000000.0, 500000.0, 333333.333, 250000.0, 200000.0, 166666.667, 142857.143, 125000.0,
111111.111, 100000.0, 66666.667, 50000.0, 40000.0, 33333.333, 25000.0, 20000.0};

// You can assign any interval for any timer here, in Hz
double PWM_Freq[NUMBER_ISR_PWMS] =
double PWM_Freq[] =
{
1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f, 8.0f,
9.0f, 10.0f, 15.0f, 20.0f, 25.0f, 30.0f, 40.0f, 50.0f
};

// You can assign any interval for any timer here, in milliseconds
uint32_t PWM_DutyCycle[NUMBER_ISR_PWMS] =
double PWM_DutyCycle[] =
{
5, 10, 20, 30, 40, 45, 50, 55,
60, 65, 70, 75, 80, 85, 90, 95
5.0, 10.0, 20.0, 30.0, 40.0, 45.0, 50.0, 55.0,
60.0, 65.0, 70.0, 75.0, 80.0, 85.0, 90.0, 95.0
};



////////////////////////////////////////////////

void setup()
Expand Down
9 changes: 5 additions & 4 deletions examples/ISR_Changing_PWM/ISR_Changing_PWM.ino
Expand Up @@ -28,6 +28,7 @@

#define MAX_STM32_PWM_FREQ 1000

// To be included only in main(), .ino with setup() to avoid `Multiple Definitions` Linker Error
#include "STM32_Slow_PWM.h"

#define LED_OFF LOW
Expand Down Expand Up @@ -87,14 +88,14 @@ double PWM_Freq1 = 1.0f;
double PWM_Freq2 = 2.0f;

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

// You can assign any duty_cycle for any PWM here, from 0-100
uint32_t PWM_DutyCycle1 = 50;
double PWM_DutyCycle1 = 10.0;
// You can assign any duty_cycle for any PWM here, from 0-100
uint32_t PWM_DutyCycle2 = 90;
double PWM_DutyCycle2 = 90.0;

// Channel number used to identify associated channel
int channelNum;
Expand Down

0 comments on commit 655e979

Please sign in to comment.