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

Commit

Permalink
v1.1.0 for AVRDD and core 1.5.1
Browse files Browse the repository at this point in the history
### Release v1.1.0

1. Add support to AVRDD (AVR64DD, AVR32DDx, AVR16DD, etc.)
2. Modify to use either breaking DxCore v1.5.1+ or v1.4.10-
  • Loading branch information
khoih-prog authored Dec 31, 2022
1 parent 7a4ddea commit 3090d0e
Show file tree
Hide file tree
Showing 13 changed files with 80 additions and 26 deletions.
8 changes: 4 additions & 4 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,23 +15,23 @@ 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.19) or Platform.io version
* `DxCore` Core Version (e.g. Arduino DxCore core v1.4.10)
* `DxCore` Core Version (e.g. Arduino DxCore core v1.5.1)
* Board (e.g. AVR128DA64, AVR128DB48, AVR64DB32, etc.)
* Contextual information (e.g. what you were trying to achieve)
* Simplest possible steps to reproduce
* Anything that might be relevant in your opinion, such as:
* Operating system (Windows, Ubuntu, etc.) and the output of `uname -a`
* Network configuration

Please be educated, civilized and constructive. Disrespective posts against [GitHub Code of Conduct](https://docs.github.com/en/site-policy/github-terms/github-event-code-of-conduct) will be ignored and deleted.

### Example

```
Arduino IDE version: 1.8.19
Arduino DxCore core v1.4.10
OS: Ubuntu 20.04 LTS
Arduino DxCore core v1.5.1
Board: Curiosity AVR128DB48
Linux xy-Inspiron-3593 5.15.0-53-generic #59~20.04.1-Ubuntu SMP Thu Oct 20 15:10:22 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux
Linux xy-Inspiron-3593 5.15.0-56-generic #62~20.04.1-Ubuntu SMP Tue Nov 22 21:24:20 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux
Context:
I encountered a crash while trying to use this library
Expand Down
6 changes: 6 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
## Table of Contents

* [Changelog](#changelog)
* [Release v1.1.0](#release-v110)
* [Initial Release v1.0.0](#initial-release-v100)

---
Expand All @@ -26,6 +27,11 @@
## Changelog


### Release v1.1.0

1. Add support to AVRDD (AVR64DD, AVR32DDx, AVR16DD, etc.)
2. Modify to use either breaking DxCore v1.5.1+ or v1.4.10-

### Initial Release v1.0.0

1. Initial release to support Arduino **AVRDx-based boards (AVR128Dx, AVR64Dx, AVR32Dx, etc.) using DxCore**
Expand Down
6 changes: 5 additions & 1 deletion examples/PWM_Basic/PWM_Basic.ino
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,11 @@
// PF0-3: Not PWM
// PF4-5: TCB

#define pinToUse PIN_PC3 //PIN_PF5
#if defined(PIN_PF5)
#define pinToUse PIN_PF5
#else
#define pinToUse PIN_PC0
#endif

//creates pwm instance
Dx_PWM* PWM_Instance;
Expand Down
6 changes: 5 additions & 1 deletion examples/PWM_DynamicDutyCycle/PWM_DynamicDutyCycle.ino
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,11 @@
// PF0-3: Not PWM
// PF4-5: TCB

#define pinToUse PIN_PF5
#if defined(PIN_PF5)
#define pinToUse PIN_PF5
#else
#define pinToUse PIN_PC0
#endif

//creates pwm instance
Dx_PWM* PWM_Instance;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,11 @@
// PF0-3: Not PWM
// PF4-5: TCB

#define pinToUse PIN_PF5
#if defined(PIN_PF5)
#define pinToUse PIN_PF5
#else
#define pinToUse PIN_PC0
#endif

//creates pwm instance
Dx_PWM* PWM_Instance;
Expand Down
6 changes: 5 additions & 1 deletion examples/PWM_DynamicFreq/PWM_DynamicFreq.ino
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,11 @@
// PF0-3: Not PWM
// PF4-5: TCB

#define pinToUse PIN_PF5
#if defined(PIN_PF5)
#define pinToUse PIN_PF5
#else
#define pinToUse PIN_PC0
#endif

//creates pwm instance
Dx_PWM* PWM_Instance;
Expand Down
9 changes: 7 additions & 2 deletions examples/PWM_Multi/PWM_Multi.ino
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,13 @@
// PF0-3: Not PWM
// PF4-5: TCB

// Be careful to select pins for different frequencies
uint32_t PWM_Pins[] = { PIN_PB2, PIN_PC0, PIN_PF4, PIN_PF5 };
#if defined(PIN_PF5)
// Be careful to select pins for different frequencies
uint32_t PWM_Pins[] = { PIN_PC0, PIN_PF4, PIN_PF5 };
#else
// Be careful to select pins for different frequencies
uint32_t PWM_Pins[] = { PIN_PC0 };
#endif

float frequency[] = { 2000.0f, 3000.0f, 4000.0f, 8000.0f };
float dutyCycle[] = { 20.0f, 30.0f, 40.0f, 80.0f };
Expand Down
9 changes: 7 additions & 2 deletions examples/PWM_MultiChannel/PWM_MultiChannel.ino
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,13 @@
// PF0-3: Not PWM
// PF4-5: TCB

// Be careful to select pins for different frequencies
uint32_t PWM_Pins[] = { PIN_PB2, PIN_PC0, PIN_PF4, PIN_PF5 };
#if defined(PIN_PF5)
// Be careful to select pins for different frequencies
uint32_t PWM_Pins[] = { PIN_PC0, PIN_PF4, PIN_PF5 };
#else
// Be careful to select pins for different frequencies
uint32_t PWM_Pins[] = { PIN_PC0 };
#endif

float dutyCycle[] = { 20.0f, 30.0f, 40.0f, 80.0f };

Expand Down
6 changes: 5 additions & 1 deletion examples/PWM_Waveform/PWM_Waveform.ino
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,11 @@
// PF0-3: Not PWM
// PF4-5: TCB

#define pinToUse PIN_PF5
#if defined(PIN_PF5)
#define pinToUse PIN_PF5
#else
#define pinToUse PIN_PC0
#endif

//creates pwm instance
Dx_PWM* PWM_Instance;
Expand Down
2 changes: 1 addition & 1 deletion library.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "Dx_PWM",
"version": "1.0.0",
"keywords": "timing, device, control, timer, pwm, pwm-driver, pwm-frequency, dynamic-pwm, duty-cycle, hardware-based-pwm, multi-channel-pwm, waveform-generator, mission-critical, accuracy, non-blocking, megaavr, avr-da, avr-db, avr-dd, dxcore, avr128dx, avr64dx, avr32dx, megatinycore, dx-timerinterrupt, tcb-timers",
"description": "This library enables you to use Hardware-based PWM channels on Arduino AVRDx-based boards (AVR128Dx, AVR64Dx, AVR32Dx, etc.), using DxCore, to create and output PWM. The most important feature is they're purely hardware-based PWM channels, supporting very high PWM frequencies. Therefore, their executions are not blocked by bad-behaving functions or tasks. This important feature is absolutely necessary for mission-critical tasks. These hardware-based PWMs, still work even if other software functions are blocking. Moreover, they are much more precise (certainly depending on clock frequency accuracy) than other software-based PWM using ISR, millis() or micros(). That's necessary if you need to control devices requiring high precision. New efficient setPWM_manual function to facilitate waveform creation using PWM.",
"description": "This library enables you to use Hardware-based PWM channels on Arduino AVRDx-based boards (AVR128Dx, AVR64Dx, AVR32Dx, etc.), using DxCore, to create and output PWM. The most important feature is they're purely hardware-based PWM channels, supporting very high PWM frequencies. Therefore, their executions are not blocked by bad-behaving functions or tasks. This important feature is absolutely necessary for mission-critical tasks. These hardware-based PWMs, still work even if other software functions are blocking. Moreover, they are much more precise (certainly depending on clock frequency accuracy) than other software-based PWM using ISR, millis() or micros(). That's necessary if you need to control devices requiring high precision. New efficient setPWM_manual function to facilitate waveform creation using PWM. Now supporting AVRDD and DxCore v1.5.1",
"authors":
{
"name": "Khoi Hoang",
Expand Down
4 changes: 2 additions & 2 deletions library.properties
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
name=Dx_PWM
version=1.0.0
version=1.1.0
author=Khoi Hoang
maintainer=Khoi Hoang <khoih.prog@gmail.com>
sentence=This library enables you to use Hardware-based PWM channels on Arduino AVRDx-based boards (AVR128Dx, AVR64Dx, AVR32Dx, etc.), using DxCore, to create and output PWM.
paragraph=The most important feature is they're purely hardware-based PWM channels, supporting very high PWM frequencies. Therefore, their executions are not blocked by bad-behaving functions or tasks. This important feature is absolutely necessary for mission-critical tasks. These hardware-based PWMs, still work even if other software functions are blocking. Moreover, they are much more precise (certainly depending on clock frequency accuracy) than other software-based PWM using ISR, millis() or micros(). That's necessary if you need to control devices requiring high precision. New efficient setPWM_manual function to facilitate waveform creation using PWM.
paragraph=The most important feature is they're purely hardware-based PWM channels, supporting very high PWM frequencies. Therefore, their executions are not blocked by bad-behaving functions or tasks. This important feature is absolutely necessary for mission-critical tasks. These hardware-based PWMs, still work even if other software functions are blocking. Moreover, they are much more precise (certainly depending on clock frequency accuracy) than other software-based PWM using ISR, millis() or micros(). That's necessary if you need to control devices requiring high precision. New efficient setPWM_manual function to facilitate waveform creation using PWM. Now supporting AVRDD and DxCore v1.5.1
category=Device Control
url=https://github.com/khoih-prog/Dx_PWM
architectures=megaavr
Expand Down
35 changes: 26 additions & 9 deletions src/Dx_PWM.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,12 @@
This is pure hardware-based PWM
Version: 1.0.0
Version: 1.1.0
Version Modified By Date Comments
------- ----------- ---------- -----------
1.0.0 K.Hoang 09/11/2022 Initial coding to support AVR Dx (AVR128Dx, AVR64Dx, AVR32Dx, etc.) using DxCore
1.1.0 K.Hoang 30/12/2022 Add support to AVR DD (AVR64DD, AVR32DDx, AVR16DD, etc.) using breaking DxCore v1.5.1+
*****************************************************************************************************************************/

#pragma once
Expand Down Expand Up @@ -57,13 +58,22 @@

#elif ( defined(__AVR_AVR64DD32__) || defined(__AVR_AVR64DD28__) || defined(__AVR_AVR64DD20__) || defined(__AVR_AVR64DD14__) )
#define BOARD_NAME F("AVR64DD")
#error AVR64DD not supported yet by the DxCore
#if ( (DXCORE_MAJOR == 1) && (DXCORE_MINOR < 5) )
#error AVR64DD not supported yet
#endif
#elif ( defined(__AVR_AVR32DD32__) || defined(__AVR_AVR32DD28__) || defined(__AVR_AVR32DD20__) || defined(__AVR_AVR32DD14__) )
#define BOARD_NAME F("AVR32DD")
#error AVR32DD not supported yet by the DxCore

#if ( (DXCORE_MAJOR == 1) && (DXCORE_MINOR < 5) )
#error AVR32DD not supported yet
#endif

#elif ( defined(__AVR_AVR16DD32__) || defined(__AVR_AVR16DD28__) || defined(__AVR_AVR16DD20__) || defined(__AVR_AVR16DD14__) )
#define BOARD_NAME F("AVR16DD")
#error AVR16DD not supported yet by the DxCore

#if ( (DXCORE_MAJOR == 1) && (DXCORE_MINOR < 5) )
#error AVR16DD not supported yet
#endif

////////////////////////// __AVR_DU__ //////////////////////////

Expand Down Expand Up @@ -100,13 +110,13 @@
////////////////////////////////////////

#ifndef DX_PWM_VERSION
#define DX_PWM_VERSION F("Dx_PWM v1.0.0")
#define DX_PWM_VERSION F("Dx_PWM v1.1.0")

#define DX_PWM_VERSION_MAJOR 1
#define DX_PWM_VERSION_MINOR 0
#define DX_PWM_VERSION_MINOR 1
#define DX_PWM_VERSION_PATCH 0

#define DX_PWM_VERSION_INT 1000000
#define DX_PWM_VERSION_INT 1001000
#endif

////////////////////////////////////////
Expand Down Expand Up @@ -142,6 +152,11 @@
////////////////////////////////////////
////////////////////////////////////////

// From DxCore v1.5.1, must use __PeripheralControl instead of PeripheralControl
#if ( (DXCORE_MAJOR == 1) && (DXCORE_MINOR >= 5) )
#define PeripheralControl __PeripheralControl
#endif

extern uint8_t PeripheralControl;

////////////////////////////////////////
Expand Down Expand Up @@ -260,6 +275,8 @@ class Dx_PWM

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

#if defined(TCA1)

void setPeriod_TimerA1(uint32_t microseconds) __attribute__((always_inline))
{
// TCA Clock is F_CPU / 64, 375.0KHz for 24MHz
Expand Down Expand Up @@ -320,7 +337,7 @@ class Dx_PWM

PWM_LOGDEBUG3("setPeriod_TimerA1: pwmPeriod =", pwmPeriod, ", _actualFrequency =", _actualFrequency);
}

#endif
///////////////////////////////////////////

void setPeriod_TimerB(unsigned long microseconds) __attribute__((always_inline))
Expand Down Expand Up @@ -511,7 +528,7 @@ class Dx_PWM

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

#ifdef TCA1
#if defined(TCA1)
/* case TIMERA1:
*/
tcaroute &= (0x18);
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 @@ -9,11 +9,12 @@
This is pure hardware-based PWM
Version: 1.0.0
Version: 1.1.0
Version Modified By Date Comments
------- ----------- ---------- -----------
1.0.0 K.Hoang 09/11/2022 Initial coding to support AVR Dx (AVR128Dx, AVR64Dx, AVR32Dx, etc.) using DxCore
1.1.0 K.Hoang 30/12/2022 Add support to AVR DD (AVR64DD, AVR32DDx, AVR16DD, etc.) using breaking DxCore v1.5.1+
*****************************************************************************************************************************/

#pragma once
Expand Down

0 comments on commit 3090d0e

Please sign in to comment.