初始化pwm程序:voidPWM_INIT(){TMOD=0X02;//定时器0工作于8位自动重载模式TH0=0xfc;TL0=0xfc;TR0=1;CMOD=0x04;//CPS1=0CPS0=1,选择PCA的时钟源为定时器0的溢出CL=0;//PCA计数器清零CH=0;CCAP0H=0;//初始化占空比为0
/******************************************///PCA初始化函数void PCA_Init (void){ //CIDL --- CPS2 CPS1CPS0 ECF CMOD = 0x80;//空闲时关闭PCA,计数时钟为Fosc/12,关闭计数器溢出中断CF//CF CR - - - -