On AT89S52 platform .T0 interrupt_routine like following:
void Timer0(void) interrupt TF0_VECTOR { static unsigned char data cF=0; static unsigned char data c=0, cC= 0; T0RC = -(SYSCLK/1000/12)*INTERVAL; c = c + 1; cqq =cqq + 1; bMR = ~bMR; bFF = ~bFF; }
... AUXR = 0X00; T0RC = -(SYSCLK/1000/12)*INTERVAL; TMOD = 0X01; TCON = 0X01; TR0 = 1; SCON = 0X50; RCAP2 = -(SYSCLK/32/BAUDRATE); T2MOD = 0X00; T2CON = 0X34; IE = 0X97; IP = 0X00; ...
It's impossible to know what's wrong with variable cqq --- you didn't show its definition. What you're observing here could, in principle, be a compiler bug. Only a look at the actual assembly generated by the compiler could tell. You should also give exact version numbers and flags used, for all tools involved, to clarify this. Are this program on the AT89S52 and the other one running on the C8051F020 the same (i.e. the same .hex file programmed into both)? If they aren't, all kinds of things could change the outcome.
Sorry,I thought that TH0 and TL0 are two continuous units,so I define T0RC as: sfr16 T0RC = 0X8A;The runnig result doesn't refresh TH0 but TL1,Maybe any conflict happening to reset the value of var cC,and so on.