Hello~everybody
I would like to ask you a question about my MCU–STC15(this one: [url]http://www.kynix.com/Detail/189968/STC1553.html[/url].
Can the register–CCAPnH of STC MUC read its value? What’s more,CCAP2H = 255*(spd)/100; // The duty cycle which need to set evaluated to captured register HICH of module2 in PCA.In the following code,if coefficient is 255,PWM output can’t be debugged and it is a pimping output. However,the PWM output can be debugged normally when coefficient is 256. Does anyone know what occurred ?
[code]void PWM_Init(void)
{
AUXR1 = (AUXR1 &~ (3<<4)) | (0<<4); //choose IO port to be P12_P11_P10_P37 acquiescently
P3M1 &= 0x7F;P3M0 &=0x7F; //set P3.7 port to be Quasi two-way
CCON = 0; //initialized PCA controlling register
//PCA timer stop
//clear CF sign
//clear the module interrupt sign
CL = 0; /restore PCA register
CH = 0;
CMOD = 0x0A; //set PCA time SYSclk/4,ECF=0 ban PCA timer overflow interrupt ,PWM frequency=PCA time input /256,about equal to 11.7K
PCA_PWM2 = 0x00;//PCA module2 work in wight PWM
CCAPM2 = 0x42; //PCA module2 is eight PWM mode
CR = 1;
}
void MotoSpeed_Setting(unsigned char spd)
{
CCAP2H = 255*(spd)/100; //The duty cycle which need to set evaluated to captured register HICH of module2 in PCA
}[/code]