对我们来说,PWM模块是最重要的部分,好了那就做个呼吸灯吧!
/***************************** PWM学习 **********************************
我采用宏定义方式进行了PWM的初始化,定时器口配置在 #include "PORT_cfg.h" //管脚复用配置
#define PWM_INIT() tpm_pwm_init(TPM0, TPM_CH1, 10000, 0); \
tpm_pwm_init(TPM2, TPM_CH0, 10000, 0); \
tpm_pwm_init(TPM2, TPM_CH1, 10000, 0)
//初始化PWM设置:PTB18 PTB19 PTD1 10KHZ
#define PWM1_SET(duty) tpm_pwm_duty(TPM2, TPM_CH0,duty) //LED0
#define PWM2_SET(duty) tpm_pwm_duty(TPM2, TPM_CH1,duty) //LED1
#define PWM3_SET(duty) tpm_pwm_duty(TPM0, TPM_CH1,duty) //LED2
*******************************************************************************/
|