Hello all,
I have a very typical problem with a twist. Here goes:
I have a main loop running a piece of code. However, upon receiving character '0' from serial port (or any 8bit code for that matter), I want to read 8 or 16 or lets say n number of bytes from serial port.
So here is what I did, I created an updateFlag bit which gets set whenver the true code is reached and the ISR quits. Whenever in the main loop I reach the place for checking updateFlag, I deactivate the ISR for Serial Port and assuming that now the serial port will act just as normal, I run a debug code of reading a byte and outing it. Only the serial port interrupt flag remains inactive while I am in that function.
So the ISR goes like:
ISR_SP: JBC TI, QUITY ; if TI caused it, just quit MOV A, SBUF ; if '0' = 30 then update the IDATA ADD A, #-30H ; else skip the update JNZ QUITY SETB UpdateFlag QUITY: RETI ; if TX irq just returns
and the main loop:
while (1) { if (UpdateFlag == 1) { /*---------------------------- Debug ------------------------*/ EA = 0; choice = GetByte();
choice++;
OutByte(choice);
UpdateFlag = 0;
EA = 1; } // Some functions here
My problem is this that the ISR works fine if I dont involve serial port reading writing, that ISR would turn on or off any port correctly upon receiving character '0'.
Similarly the GetByte and OutByte routines work fine as well when Serial port is not on interrupt.
Its only after combining both I end up in problems, can anyone see any potential problem in the approach?
Thanks in advance
Makhan