|
|
View previous topic :: View next topic |
Author |
Message |
Einly
Joined: 10 Sep 2003 Posts: 60
|
RS232 |
Posted: Thu Dec 30, 2004 9:22 am |
|
|
Dear all,
I am using PIC16f876 to send serial data to a computer. I am using hardware UART.
1) Before I write to TXREG Register, I will check bit 1 of the TXSTA. Since there is no handshaking line on the PIC (DTR/RTS), I just connect the CTS and the RTS of the 9 pin cable together. May I know when the data in the TSR REGISTER be transmitted out since the 2 line have been connected together? Will it been sent although the pc part have not ready to read it?
2) What is the usual size of the serial port buffer in the computer? Can it be set? If the serial port buffer is full, will the data be lost?
3) If the data lost happens, what is the common practice? Is it by introducing hardware handshaking or keep on polling the data in the pc part?
4) If it is to introduce hardware handshaking, how to do in using PIC16f876 since it has not these 2 lines (RTS/CTS)? I do not do software handshaking because this will slow down the system.
Thanks a lot _________________ Einly |
|
|
SherpaDoug
Joined: 07 Sep 2003 Posts: 1640 Location: Cape Cod Mass USA
|
|
Posted: Thu Dec 30, 2004 9:43 am |
|
|
You can give the PIC DTR & RTS lines if you want them, though most PC programs don't use them anyway. Just run them through a RS232 level shifter (like a MAX232) just as you do the TXD and RXD lines and run them to port pins. It is then up to your PIC software to query and drive them.
My programming is fairly primitive and I assume the PC buffer is big enough to swallow a whole PIC packet, which rarely exceeds 16 bytes, and that the PC will have read it and disposed of it by the time my next packet is ready.
For data comming into the PIC I usually parse and execute it byte by byte as it comes in. I don't buffer it at all unless I want to parrot back a bad command for debugging. _________________ The search for better is endless. Instead simply find very good and get the job done. |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|