#include <STC12C2052AD.H>
void main()
{
CCON=0; //关PCA、清0全部PCA中断标志
CL=0;
CH=0;
CCAP0H = 0xC0; //模块0输出25%占空比PWM
CCAP1H = 0x40; //模块1输出75%占空比PWM
CMOD = 0x00; //模式:FSOC/12、关ECF禁止PCA中断
CCAPM0 = 0x42; //模块0设置PWM
CCAPM1 = 0x42; //模块1相同设置
PCA_PWM0 &= 0xFC; //第9位ECAP0H=0,该位在需要0%占空比时设为1
PCA_PWM1 &= 0xFC; //第9位ECAP1H=0
CR=1;
while(1);
}
|