??? 06/23/06 10:34 Modified: 06/23/06 10:37 Read: times |
#118932 - Problem solved. Really? Responding to: ???'s previous message |
The way you have solved your problem is horrible (that DELAY routine is unelegant). You want to manage the serial port via interrupts but only regarding reception, not transmission. The point is that the 8051 family has only one vector: serial port (as a whole), and not two (serial port, reception, and serial port, transmission). If you want to manage serial reception via interrupt then you have to filter out the serial transmision. The point is that you have to keep record of that event (a character has been sent out and the port hardware is ready for another one) so that the "normal" software (running in foreground) can detect it and send another one. This is extremely easy: define and use a copy of TI flag (call it PSEUDO_TI or whatever you like, and place it in the bit-addressable area of the internal RAM). So, you can build up an intrerrupt service routine looking like this:
SERIAL_PORT_SERVICE: JBC RI,RECEPTION ;¿reception? SETB PSEUDO_TI ; No: end of transmission. Keep record of TI flag CLR TI RETI RECEPTION: (...) Then, the software in foreground can be written this way: (...) JNB PSEUDO_TI,$ ; forget about TI flag and use its soft copy CLR PSEUDO_TI (...) |