Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expose PWM functions via analogWrite and friends #1

Open
maxgerhardt opened this issue Jun 18, 2021 · 0 comments
Open

Expose PWM functions via analogWrite and friends #1

maxgerhardt opened this issue Jun 18, 2021 · 0 comments
Labels
Component: DAC Regarding the DAC component Component: PWM Regarding the PWM component enhancement New feature or request

Comments

@maxgerhardt
Copy link
Member

maxgerhardt commented Jun 18, 2021

Currently calling analogWrite will attempt to write the value into the DAC peripheral, producing an exact analog voltage.

https://github.com/CommunityGD32Cores/GD32Core-New/blob/92bdf02a90e61e9a2b20ffc1adf81671175fbdc5/cores/arduino/wiring_analog.c#L127-L135

The regulard Arduino API analogWrite would start a PWM output with some default parameters (e.g., PWM frequency, PWM resolution etc.) on that pin.

The functionality should be changed so that analogWrite also starts a PWM wave and friend functions for setting resolution and frequency should be added.

Currently, PWM functionality is available via the PWM class

https://github.com/CommunityGD32Cores/GD32Core-New/blob/92bdf02a90e61e9a2b20ffc1adf81671175fbdc5/libraries/pwm/examples/pwmoutput/pwmoutput.ino#L1-L11

(and is partly not working, see #4)

The DAC functionality should still be accessible of course -- it has to be thought to which API it should be moved, or if an "auto-detection" between PWM and DAC should be made.

@maxgerhardt maxgerhardt added enhancement New feature or request Component: DAC Regarding the DAC component Component: PWM Regarding the PWM component labels Jun 18, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Component: DAC Regarding the DAC component Component: PWM Regarding the PWM component enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant