Closed m4tto closed 3 years ago
Hi,
The duty_cycle got from _mtk_mhal_pwm_group_get(...) will be 0 due to certain design reason, which makes this duty_cycle unable to be directly applied.
Actually I've checked that the current API functions were initially designed to be:
So your example code will become the following:
printf("set`` duty 1\n");
ret |= mtk_os_hal_pwm_config_freq_duty_normal(PWM_CTRL_GROUP, PWM_ON_OFF_CH, 1000, 500);
printf("start 1\n");
ret |= mtk_os_hal_pwm_start_normal(PWM_CTRL_GROUP, PWM_ON_OFF_CH);
printf("set duty 2\n");
ret |= mtk_os_hal_pwm_config_freq_duty_normal(PWM_CTRL_GROUP, PWM_TACH_SET_CH, 2500, 500);
printf("start 2\n");
ret |= mtk_os_hal_pwm_start_normal(PWM_CTRL_GROUP, PWM_TACH_SET_CH);
The PWM sample code may also be misleading, we will modify them in the future update.
I see, thank you for your prompt reply.
Hi,
I'm seeing strange behavior in the configuration of a PWM controller. Even If I configure two channels with different freq and duty, at start they both have the same period and duty equal to the last set.
This is the example code:
After start, both pwm have 2.5KHz frequency and 50% duty. If I call mtk_os_hal_pwm_config_freq_duty_normal after start, on each channel, I can configure them as I want. I suspect this is not the intended behaviour. Probably the cause is here (mhal_pwm.c lines 369,370):
frequency and duty are not set using those get from _mtk_mhal_pwm_group_get