>Which PIC are you using? I am using a PIC18F242... >Why are you using handshaking lines? >Why are you using interrupts for transmit? I am using handshaking lines the same way a modem uses it.. RTS CTS to tell when to send and receive data... I am using Interrupts for transmit because the design was not supposed to be used only for loopback test.. the loopback test was used only to check whether communication using interrupts was working perfectly.. which ofcourse I found out was not.. thanks for the reply.. regards... "Vitaliy" wrote in message news:043401c74c6b$92e65a10$6f02a8c0@WS11... > jtroxas wrote: >> hello.. >> I am doing a serial communication and doing a loopback test through a PIC >> most of the times the last two or four bytes of a message is not being >> sent back to the sending computer from the PIC... > > Which PIC are you using? > >> the computer pulls down a pin to 0volts to tell the PIC that a >> transmission is over and up to tell the PIC that its about to initiate a >> transmission.. The PIC signal a clear to send message by raising another >> pin to 5 volts... >> >> when the PIC has sent a reply it pulls down this other pin to low and >> disables Transmit Interrupt... > > Why are you using handshaking lines? > > Why are you using interrupts for transmit? > >> the problem I think is the timing when raising and lowering the said >> pins. >> when the pins are lowered while some data is still in the PIC's hardware >> buffer.. Some of the last 4 bytes are being lost.. maybe 2 when received >> and 2 when transmitting.. I got an idea of checking TXSTA register's TRMT >> bit to check whether the shift register is empty or not before sending a >> "message sent" signal to the computer and disabling interrupt so as not >> to >> loose the last data sitting on the transmit buffer.. >> >> on the other hand.. Is there a way to check the PIC's Receiving Shift >> register if it has data or currently shifting data.. I would like to >> avoid >> waiting or delay code if it can be avoided... > > To check if there's data in the RCREG, you need to check the RCIF bit in > PIR1. > > The most straightforward way of implementing what you're doing, is to > enable > Rx interrupt, and in the ISR put the byte you received into the TXREG > (without enabling the Tx interrupt). > > Best regards, > > Vitaliy > > > -- > http://www.piclist.com PIC/SX FAQ & list archive > View/change your membership options at > http://mailman.mit.edu/mailman/listinfo/piclist > -- http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist