> From: Thomas Olsson[SMTP:piclist@ARMWARE.DK] > Sent: Saturday, March 13, 2004 7:00 PM > To: PICLIST@MITVMA.MIT.EDU > Subject: [PIC:] Emptying TXREG on 16F62x USART > Hi, > I've been looking at app notes and data sheets, but I haven't found how to > do this. > Basically I've got a 16F62x which has been transmitting data with the > USART, and has been stopped (due to a bus conflict), and then later it > needs to try again. > When this happens, it needs to somehow empty TXREG of the data from the > previous aborted transmission. Otherwise the first byte sent will be one of > those that it didn't get to send last time. The internal TSR is apparently > emptied at some point, probably when TXEN is cleared, but I can't find hard > information about this either. In practice, it is always only 1 extra byte > lingering, and it corresponds to whatever was in TXREG when the > transmission was aborted. > So, does anyone know how discard the contents of TXREG and force it into > the 'empty' state (where TXIF gets set etc.)? > I've tried many things already, e.g. turning the USART off and on, but that > doesn't do it. > Thanks, > Thomas. The transmitter empties its buffer by sending the contents out of the serial output. This is what you are trying to avoid, but I don't think that there is any direct way to remove bytes from the send FIFO. If your chip multiplexes the serial output with another function on the same pin, you can try setting the pin to input. This should suppress the output while the UART is sending. To avoid letting the output go low while it is disconnected, put a pullup resistor on it to Vdd. After enough time has gone by to send two bytes (the usual size of the FIFO), turn the output back on. John Power -- http://www.piclist.com hint: The PICList is archived three different ways. See http://www.piclist.com/#archives for details.