Hi, The UART will generate interrupt once interrupts are enabled even if you dont write into txreg. Any way you know the problem now I think. So you can find other means of overcoming this. bye ramana -----Original Message----- From: Michael Shiloh [mailto:mshiloh@MEDIABOLIC.COM] Sent: Friday, November 24, 2000 1:48 AM To: PICLIST@MITVMA.MIT.EDU Subject: [PIC]: problems with interrupt driven uart, 16C63 > The answer is like this. > a. look at pchar routine > b. in the else clause of if running add a line SerTxBufferAppend(c) > > You program should run fine. > The reason gor not starting is the moment you enable interrupts the tx > interrupt finds nothing in th ebuffer and disbles every thing hi ramana, thanks for taking the time to answer. i appreciate your assistance my logic for the pchar routine is this: 1. if the uart is running, add to the buffer using SerTxBufferAppend(c). 2. if it is not running (the else clause of the "if running") then the uart must be started. the only way to start the uart is by writing to TXREG. In addition, the transmit interrupt must be enabled, so that once this character is transmitted, an interrupt will be generated which will cause the isr to look at the buffer to see if there is anything else to transmit. finally, the running flag must be set, so that subsequent calls to pchar will add to the buffer and not try to restart the uart. thus, i don't believe it is necessary and in fact it would be in error to write to the buffer. having said all this, obviously there is a mistake someowhere in my logic or else it would be working! comments? i include below just pchar() and the isr: /* * print the given character * * a simple description for a lot of work. * this function must first determine whether the * interrupt ISR is running or not, as if not it * must be enabled and the character must be placed * directly in the uart. * * if the ISR is running, the character is placed * in the transmit buffer only if the buffer is not full * * RETURNS: * !OK if the transmit buffer is full * OK otherwise */ char pchar (char c) { char full; char retval = OK; /* assume everything will work */ disable_interrupt( GIE ); /* disable global interrupts */ if (running) /* transmitter running, add to queue */ { full = SerTxBufferFull(); /* check transmit buffer for fullness */ if (!full) SerTxBufferAppend(c); else retval = 1; /* my compiler doesn't like !OK */ } else /* transmitter is not running, xmit now */ { TXREG = c; /* turn on transmit interrupts */ set_bit( STATUS, RP0 ); set_bit( PIE1, TXIE); /* enable transmit interrupts */ clear_bit( STATUS, RP0 ); running = TRUE; /* indicate we are running */ } enable_interrupt( GIE ); /* enable global interrupts */ return (retval); } void interrupt( void ) { char c; if (PIR1 & txif_bitmask) /* transmit done interrupt */ { /* are there more chars to transmit? */ c = SerTxBufferRemove(); /* null signifies end of buffer */ if (c) { TXREG = c; } /* remove pointer is left at next char */ else { set_bit( STATUS, RP0 ); clear_bit( PIE1, TXIE); /* disable transmit interrupts */ clear_bit( STATUS, RP0 ); running = FALSE; } /* remove pointer is left pointing at this null */ } } /* interrupt */ -- http://www.piclist.com hint: PICList Posts must start with ONE topic: [PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: ->Ads -- http://www.piclist.com hint: PICList Posts must start with ONE topic: [PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: ->Ads