>That's definitely the wrong way to do it. If you absolutely *need* to use >handshaking lines, you disable the line only after you check the flag that >tells you the message was sent, not after you put your last byte into TXREG Yeah that's what I am thinking..But even if checking the TRMT flag I thought theres no way of really telling 100% percent that the last 2 bytes in the USART buffer were sent.. it just means that shift register is empty.. what if at the time of checking the flag the USART is in the process of moving TXREG to the shiftregister( the shift register will be empty and theres still data in the TXREG).. its very remote but as what they say if its possible it will happen.. and theres no TRMT for USART receive or something similar.. maybe its easier to just add the null bytes at the end of every message and make everything simpler.. I dont have to code an RTS\CTS delay or monitor the receive buffer if an end byte is received before doing anything with the buffer.. > Are you controlling the PC handshake lines *directly*? yes I am controlling it directly.. coz I think there are other things besides turning RTS\CTS on and off that comes with turning Handshaking On on the PC's serial port that I dont completely understand and dont want to handle in code on the PIC side... plus I am using the RTS CTS lines as a secondary check to tell for sure if ever the wire connecting the PC to PIC is suddenly disconnected.. as I am using a MAX232 theres no room for the other SerialPort Pins.. regards...... "Vitaliy" wrote in message news:11ab01c74ca2$80400280$6f02a8c0@WS11... > jtroxas wrote: > > I am finding myself wanting to repeat Olin's rant about people not wanting > to answer relevant questions. :) > >> no just the 4-5 last bytes... I think its in the way I'am >> clearing\setting >> the RTS\CTS lines in the pic and PC ie.. I am doing it too early both >> from >> the PC and PIC side( Iam doing RTS\CTS manualy in code immidiately after >> the last byte is written to the USART TXREG PIC side and similar thing on >> the PC side)... > > That's definitely the wrong way to do it. If you absolutely *need* to use > handshaking lines, you disable the line only after you check the flag that > tells you the message was sent, not after you put your last byte into > TXREG. > >> but since it takes time for the data to be shifted out from the >> USARTshiftregisters and the data from TXREG be sent to the output >> shiftregister to be again shifted out and sent to the PC.. the PC will >> never received the 2 last bytes in the PIC's USART transmit buffer(TXREG >> and SHIFT REgister) because the signal that say Finished Transmitting is >> already seent just after writing the last byte to TXREG... the same thing >> happens from the PC side when transmitting so another 2-3 bytes is lost >> from the PC transmit buffer.. > > Are you controlling the PC handshake lines *directly*? > >> I think the solution is to add some waiting time before setting/clearing >> RTS\CTS(make sure that buffers are really empty).. but waiting a few >> milliseconds is a little costly(PIC is doing nothing) so I managed to try >> a hack and just add some null bytes to the end of every data I send, >> expecting that it will be trimmed out.. and remove the waiting code.. >> after all I am using interrupts for Transmit and receive.. > > Sounds like an ugly hack. Read the datasheet -- you have two useful flags > at > your disposal, which tell you exactly when the TXREG or the TSR registers > are empty. Namely, the TXIF and TRMT flags. > > 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