RTT learning PWM device

A Use these steps:  

  1. Find a PWM device device handle. rt_device_find ()

  2. PWM period and pulse width settings. rt_pwm_set (pwm_dev, PWM_DEV_CHANNEL, period, pulse);

  3. 使能 PWM 设备。rt_pwm_enable(pwm_dev, PWM_DEV_CHANNEL);//rt_pwm_disable(pwm_dev, PWM_DEV_CHANNEL);

  4. while loop once every 50 ms to modify the pulse width of the pulse, and by setting into rt_pwm_set.

  5. 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.

  6. In the fish can be operated pwm_set pwm1 PWM_DEV_CHANNEL, period, pulse command; pwm_enable / disable pwm1 PWM_DEV_CHANNEL
  7. Notes may be a direction (linear slope) period, the duty ratio of more clearly defined data structure;

Guess you like

Origin www.cnblogs.com/jieruishu/p/11803698.html