A Use these steps:
-
Find a PWM device device handle. rt_device_find ()
-
PWM period and pulse width settings. rt_pwm_set (pwm_dev, PWM_DEV_CHANNEL, period, pulse);
-
使能 PWM 设备。rt_pwm_enable(pwm_dev, PWM_DEV_CHANNEL);//rt_pwm_disable(pwm_dev, PWM_DEV_CHANNEL);
-
while loop once every 50 ms to modify the pulse width of the pulse, and by setting into rt_pwm_set.
-
The PWM pin corresponding to the channel connected to the corresponding LED pin, can see the LED constantly changed from dark to light then from light to dark variations.
- In the fish can be operated pwm_set pwm1 PWM_DEV_CHANNEL, period, pulse command; pwm_enable / disable pwm1 PWM_DEV_CHANNEL
- Notes may be a direction (linear slope) period, the duty ratio of more clearly defined data structure;