求助stc12c5a60s2的pwm调制可用在小车上吗?
时间:10-02
整理:3721RD
点击:
如题 CCON = 0; //Initial PCA control register
//PCA timer stop running
//Clear CF flag
//Clear all module interrupt flag
CL = 0; //Reset PCA base timer
CH = 0;
CMOD = 0x02; //Set PCA timer clock source as Fosc/2
//Disable PCA timer overflow interrupt
CCAP0H = CCAP0L =a; //PWM0 port output 50% duty cycle square wave
CCAPM0 = 0x42; //PCA module-0 work in 8-bit PWM mode
PCA_PWM0 = 0x03; //and no PCA interrupt
CCAP1H = CCAP1L = 255; //PWM1 port output 0% duty cycle square wave
PCA_PWM1 = 0x03;
CCAPM1 = 0x42; //PCA module-1 work in 8-bit PWM mode and no PCA interrupt
CR = 1; //PCA timer start run
EA=1;
EX0=1;
while(1);
主函数实例里的 EX0=1; 的作用是什么啊? 为什么要打开外部中断0?
//PCA timer stop running
//Clear CF flag
//Clear all module interrupt flag
CL = 0; //Reset PCA base timer
CH = 0;
CMOD = 0x02; //Set PCA timer clock source as Fosc/2
//Disable PCA timer overflow interrupt
CCAP0H = CCAP0L =a; //PWM0 port output 50% duty cycle square wave
CCAPM0 = 0x42; //PCA module-0 work in 8-bit PWM mode
PCA_PWM0 = 0x03; //and no PCA interrupt
CCAP1H = CCAP1L = 255; //PWM1 port output 0% duty cycle square wave
PCA_PWM1 = 0x03;
CCAPM1 = 0x42; //PCA module-1 work in 8-bit PWM mode and no PCA interrupt
CR = 1; //PCA timer start run
EA=1;
EX0=1;
while(1);
主函数实例里的 EX0=1; 的作用是什么啊? 为什么要打开外部中断0?