ST17H26之pwm功能

移动开发 waitig 587℃ 百度已收录 0评论

1.设置io口为pwm工作模式:

#define GPIO10_FUNC AS_PWM
#define GPIO10_OUTPUT_ENABLE 0
#define PULL_WAKEUP_SRC_GPIO7
PM_PIN_UP_DOWN_FLOAT

2.设置周期参数:

write_reg16(0x79a,727);//set pwm1 max cycle 2.7K = 2M/741

3.设置占空比:

write_reg16(0x798,363);//set pwm1 duty_cycle = 50% = 370/1000

4.启动pwm:

write_reg8(0x780,0x02);

[0]: 0–disable PWM0, 1–enable PWM0
[1]: 0–disable PWM1, 1–enable PWM1
[2]: 0–disable PWM2, 1–enable PWM2

[3]: 0–disable PWM3, 1–enable PWM3

5.关闭pwm:

write_reg8(0x780,0x00);

6.enjoy youself!


本文由【waitig】发表在等英博客
本文固定链接:ST17H26之pwm功能
欢迎关注本站官方公众号,每日都有干货分享!
等英博客官方公众号
点赞 (0)分享 (0)