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.
Currently calling
analogWritewill 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
analogWritealso starts a PWM wave and friend functions for setting resolution and frequency should be added.Currently, PWM functionality is available via the
PWMclasshttps://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.