Closed be-engineer closed 2 years ago
You might be running in the issue https://github.com/CommunityGD32Cores/ArduinoCore-GD32/issues/4.
Also, due to the code block
#if defined(PA6) && defined(PC1)
#define PWM_OUT_PIN PA6
#define LED_PIN PC13
#else
#define PWM_OUT_PIN PWM4
#define LED_PIN LED_BUILTIN
#endif
and the GD32F303CC has both PA6 and PC1 defined (source), it will attempt the PWM output on PA6, not PWM4
which is equal to PA15. ARe you measuring on PA6?
I tested it again with the following code,from PWM0-PWM5, but there is no output.,even PB6, PB5, etc.
#include <Arduino.h>
PWM pwm_output(PWM2);
void setup()
{
Serial.begin(115200);
Serial.println("Start");
pwm_output.setPeriodCycle(500, 250, FORMAT_MS);
pwm_output.start();
}
void loop() {}
I'll check it out now -- the GD32F303CC variant may not yet have its pinmap updated.
This was a bug on our side in the enabling of the timer clocks -- it has been fixed now.
In https://github.com/CommunityGD32Cores/ArduinoCore-GD32/commit/0f7e9e5c1dd51447677e06799daa8405e78cb6c9 and https://github.com/CommunityGD32Cores/ArduinoCore-GD32/commit/d142fc696944b6396c252ba16fe08ff5e8be76c7.
I've changed the PWMx default definitions to not collide with the default UART pins anymore (PA9 and PA10), see
for the current definitions.
I have personally tested every PWM0 to PWM5 output pin to be correct.
To update, please open a CLI and execute pio platform update gd32
, it should pull the newest framwork-arduinogd32
version.
I try to use this demo gd32-arduino-pwm-out.It compile with no error,but PWM4 has no wave output. My MCU is GD32F303CC.