This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

why the same 'word' can't do the same 'job'?

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;
}
when debugged,var 'c' can only switch to '0' or '1',the same to var 'cqq'.why the var can't hold value in increment? And the initial routine is following:
...
	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;
...
I am sure the interrupt_routine running because port_pin 'bMR' changed orderly.
And so ,all this word is in the other program which running on C8051F020 well.
Can you tell me what'S the different between AT89S52 and C8051F020?How can I solve this problem?
Thanks!

Parents
  • 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.

Reply
  • 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.

Children