I am using the simulator of the uvision2. According to the debugger the value of c doesn't change (I am using the serial peripheral) and the debugger never execute the Start_bit = 1; even though the SBUF = 0x46.
char c ; void SerialPort(void) interrupt 4 using 2 { if (RI == 1) { c = SBUF; if(SBUF==0x46) Start_bit = 1; RI = 0; } }
Hi I finnaly understood that the local variable is changed to zero and didn't stay at zero (which means that it doesn't succcefuly read the SBUF???). here are all my init values.
TMOD = 0x20; TH1 = 0xFB; // baud ~19200; TR1 = 1; SCON = 0x50; IE=0x90; EA = 1; ES = 1; REN = 1; RI = 0; void SerialPort(void) interrupt 4 using 2 { while(!RI) { if(ArrLenFlag==0) { ArrLen = _getkey (); ArrLenFlag = 1; } else { if(_getkey()=='S') { Start_bit = 1; SaveData(1000); SaveData(1000); } else { chr = _getkey (); SaveData(chr); } } RI = 0; TI = 0; } }