We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
Hello, I have two programs loaded in memory at different locations (not in multitasking, just loaded). Both are using the serial port and the first one uses its own ISR (interrupt service routine) for comunicating with the serial port. I did make the first program to launch the second program by jumping to its startup address. The second program starts running but there is a problem ! It cannot use the serial port anymore ! :( I use the following code in the first program to initialize the serial port: void init_ser(void){ // Use timer T1 TH1=253; // serial baud 9600 TMOD=TMOD&0x0F; // clean the T1 part TMOD=0x20|TMOD; // set timer 1 in mode 2 -> 8bit autoreload with TH1 set S0CON=0x50; PCON=PCON | 0x80; pfun = ser_int; // take the address of my ISR addrintser = (unsigned)pfun; // save it XBYTE[0x8023] = 0x02; // Put a LJMP to my ISR XBYTE[0x8024] = (uchar)((addrintser&0xff00)>>8); XBYTE[0x8025] = (uchar)(addrintser&0x00ff); PS0 = 1; TI=0; RI=0; ES0=1; // Enable serial interrupt } What can i do to restore the old serial interrupt service routine ?! I tried alot of things to do (like saving and restoring registers) but it didnt work at all !! :( Or what else can be wrong ?! Anyone has any ideea why my serial port doesnt want to work in my second program !?! Please help ! :O P.S. I have no operating system (such as RTX51), i only use an old Franklin monitor to load these programs.
I wasn't suggesting that you reinit the serial port so much as suggesting that perhaps that was a problem. If your second program is built just as any normal program, it's going to execute startup code. I noticed that your example code has writes to xdata 8000H to set the serial interrupt vector. What if (for example) the startup code for your second program zeros all xdata? It will zero out the interrupt vector set by program 1, and the serial interrupt will stop working. You need to be sure that the startup code of program #2 doesn't conflict with any work that program #1 does, or at least have it redo the work that it needs.
Also, i dont know how to make a startup code to undo the setup that program #1 did. Can you give me any example ?!
This is for my final project (i'm in the final year) so its very important for me !