-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Closed
Labels
area: PWMPulse Width ModulationPulse Width ModulationbugThe issue is a bug, or the PR is fixing a bugThe issue is a bug, or the PR is fixing a bugplatform: STM32ST Micro STM32ST Micro STM32
Description
Describe the bug
The following code snipped should generate a 5 kHz PWM signal with 50% duty cycle.
#define PWM_CONTROLLER "PWM_8"
#define PWM_PERIOD 200000 /* 200 us period = 5 kHz */
#define PWM_CHANNEL 1
void start_pwm()
{
const struct device *pwm_dev = device_get_binding(PWM_CONTROLLER);
pwm_pin_set_nsec(pwm_dev, PWM_CHANNEL, PWM_PERIOD, PWM_PERIOD / 2, 0);
}The actual signal generated is 7.5 kHz (duty cycle of 50% is correct).
Tested MCUs: STM32G431 and STM32G474.
Environment:
- OS: Linux
- Zephyr master, SHA: 1b680c8
@gmarull I'm trying to find a fix for the issue myself, but if you already have an idea what could be wrong, please let me know.
Metadata
Metadata
Assignees
Labels
area: PWMPulse Width ModulationPulse Width ModulationbugThe issue is a bug, or the PR is fixing a bugThe issue is a bug, or the PR is fixing a bugplatform: STM32ST Micro STM32ST Micro STM32