PWM工作代码:
工作原理就是宽度状态开关。
for (uint8_t i = 0; i < 100; i++) {
sl_pwm_set_duty_cycle(&sl_pwm_led0, pwm_lut);
sl_sleeptimer_delay_millisecond(6);
if (i == 0) {
sl_sleeptimer_delay_millisecond(190);
}
}
for (uint8_t i = 100; i > 0; i--) {
sl_pwm_set_duty_cycle(&sl_pwm_led0, pwm_lut);
sl_sleeptimer_delay_millisecond(6);
if (i == 100) {
sl_sleeptimer_delay_millisecond(190);
}
}