ST17H26的PWM模块
總共4路pwm。
#define GPIO10_FUNC AS_PWM
#define GPIO10_OUTPUT_ENABLE 0
#define PULL_WAKEUP_SRC_GPIO10 PM_PIN_UP_DOWN_FLOAT
//#define PULL_WAKEUP_SRC_GPIO10 PM_PIN_PULLUP_10K ?no use!
#define GPIO17_FUNC AS_PWM
#define GPIO17_OUTPUT_ENABLE 0
#define PULL_WAKEUP_SRC_GPIO17 PM_PIN_UP_DOWN_FLOAT
//#define PULL_WAKEUP_SRC_GPIO17 PM_PIN_PULLUP_10K
///*
write_reg8(0x781, 0x0f);//32M/(15+1) = 2M
write_reg16(0x79a, 16);//set pwm1 max cycle 125K = 2M/16
write_reg16(0x798, 8);//set pwm1 duty_cycle = 50% = 8/16
write_reg8(0x780, 0x02);
//*/
write_reg8(0x781, 0x0f);//32M/(15+1) = 2M
write_reg16(0x79e, 16);//set pwm2 max cycle 125K = 2M/16
write_reg16(0x79c, 8);//set pwm2 duty_cycle = 50% = 8/16
write_reg8(0x780, 0x04);
多路PWM操作時有點麻煩,要先讀出之前控制寄存器的內容,再去操作相關位。
總結
以上是生活随笔為你收集整理的ST17H26的PWM模块的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: ST17H26对接RC522读IC卡
- 下一篇: ST17H26开发小总结