ACC = P_SW1;
ACC &= ~(CCP_S0|CCP_S1); //CCP_S0=0 CCP_S1=1
ACC |=CCP_S1;
P_SW1 = ACC; //(P2.4/ECI_3,P2.5/CCP0_3,P2.6/CCP1_3,P2.7/CCP2_3)
CCON = 0;
CL = 0;
CH = 0;
CMOD = 0x02;
PCA_PWM0 = 0x00; //PCA模块0工作于8位PWM模式
CCAP0H = CCAP0L = 0x50; //PWM0的占空比为50%((100H-50H)/100H)
CCAPM0 = 0x42;
PCA_PWM1 = 0x40; //PCA的模块1工作于7位PWM
CCAP1H = CCAP1L =0x20; //PWM1的占空比为75%((80H-20H)/80H)
CCAPM1 = 0x42; //PCA的模块1为7位PWM模式 即工装上P2.6脚输出PWM1
PCA_PWM2 = 0x80;
CCAP2H = CCAP2L =0x20;
CCAPM2 = 0x42;
CR = 1;
while(1);
这是我参考datasheet李米娜的程序写的PWM程序,
为什么我用keil 3逻辑分析仪仿真的的时候我看 P2.5 p2.6 P2.7这三个口一直是高电平没有变化么。 |