📄 serial interface (rs-232) 1.how rs232 works.mht
字号:
=
href=3D"http://www.fpga4fun.com/ShopAccessories.html">Accessories</A><BR>=
<A=20
class=3Dlink href=3D"http://www.fpga4fun.com/ShopI2C.html">I2C =
bus</A><BR><A=20
class=3Dlink href=3D"http://www.fpga4fun.com/ShopLCDs.html">LCD=20
modules</A><BR><A class=3Dlink=20
=
href=3D"http://www.fpga4fun.com/ShopOpto-electronic.html">Opto-electronic=
</A><BR><A=20
class=3Dlink =
href=3D"http://www.fpga4fun.com/ShopFPGAcables.html">FPGA=20
cables</A><BR><A class=3Dlink=20
=
href=3D"http://www.fpga4fun.com/ShopOscillators.html">Oscillators</A><BR>=
<HR>
</B></FONT><BR><BR></TD>
<TD vAlign=3Dtop>
<H4>How the RS-232 serial interface works</H4>Most computers have =
one or=20
two serial RS-232 interface as standard equipment. Each interface =
has the=20
following characteristics:=20
<UL>
<LI>Uses a 9 pins connector "DB-9" (older PCs use 25 pins =
"DB-25").=20
<LI>Allows bidirectional full-duplex communication (the PC can =
send and=20
receive data at the same time).=20
<LI>Can communicate at a maximum speed of roughly 10KBytes/s.=20
</LI></UL>You can use serial communication to connect two PCs =
together,=20
for example.=20
<H4>DB-9 connector</H4>You probably already saw this connector on =
the back=20
of your PC.<BR><BR><IMG=20
=
src=3D"http://www.fpga4fun.com/images/SerialConnector.jpg"><BR><BR>It =
has 9=20
pins, but the 3 important ones are:=20
<UL>
<LI>pin 2: RxD (receive data).=20
<LI>pin 3: TxD (transmit data).=20
<LI>pin 5: GND (ground). </LI></UL>Using just 3 wires, you can =
send and=20
receive data.=20
<H4>Serial communication</H4>Data is sent one bit at a time; so =
one wire=20
is enough for each direction. Since computers usually need at =
least=20
several bits of data, the data is "serialized" before being sent. =
Data is=20
commonly sent by chunks of 8 bits. The data bit 0 is sent first, =
bit 7=20
last.=20
<H4>Asynchronous communication</H4>This interface uses an =
"asynchronous"=20
protocol. That means that no clock signal is transmitted along the =
data.=20
The receiver has to have a way to "time" itself to the incoming =
data=20
bits.<BR><BR>In the case of RS-232, that's done this way:=20
<OL>
<LI>Both side of the cable agree in advance on the communication =
parameters (speed, format...). That's done manually before =
communication=20
starts.=20
<LI>The transmitter sends a "1" when and as long as the line is =
idle.=20
<LI>The transmitter sends a "start" (a "0") before each byte=20
transmitted, so that the receiver can figure out that data is =
coming.=20
<LI>After the "start", data comes in the agreed speed and =
format, so the=20
receiver can interpret it.=20
<LI>The transmitter sends a "stop" (a "1") after each data byte. =
</LI></OL>Let's see how looks the byte 0x55 when =
transmitted:<BR><BR><IMG=20
=
src=3D"http://www.fpga4fun.com/images/SerialCommunication55.gif"><BR><BR>=
Byte=20
0x55 is 01010101 in binary.<BR>But since it is transmitted LSB =
(bit-0)=20
first, the line toggles like that: 1-0-1-0-1-0-1-0.<BR><BR>Here's =
another=20
example:<BR><BR><IMG=20
=
src=3D"http://www.fpga4fun.com/images/SerialCommunication.gif"><BR><BR>He=
re=20
the data is 0xC4, can you see it?<BR>The bits transitions are =
harder to=20
see. That illustrates how important it is for the receiver to know =
at=20
which speed the data is sent.=20
<H4>How fast can we send data?</H4>The speed is specified in baud, =
i.e.=20
how many bits-per-seconds can be sent. For example, 1000 bauds =
would mean=20
1000 bits-per-seconds, or that each bit lasts one=20
millisecond.<BR><BR>Common implementations of the RS-232 interface =
(like=20
the one used in PCs) don't allow just any speed to be used. If you =
want to=20
use 123456 bauds, you're out of luck. You have to settle to some=20
"standard" speed. Common values are:=20
<UL>
<LI>1200 bauds.=20
<LI>9600 bauds.=20
<LI>38400 bauds.=20
<LI>115200 bauds (usually the fastest you can go). </LI></UL>At =
115200=20
bauds, each bit lasts (1/115200) =3D 8.7µs. If you transmit =
8-bits data,=20
that lasts 8 x 8.7µs =3D 69µs. But each byte requires =
an extra start and=20
stop bit, so you actually need 10 x 8.7µs =3D 87µs. =
That translates to a=20
maximum speed of 11.5KBytes per second.<BR><BR>At 115200 bauds, =
some PCs=20
with buggy chips require a "long" stop bit (1.5 or 2 bits long...) =
which=20
make the maximum speed drop to around 10.5KBytes per second.=20
<H4>Physical layer</H4>The signals on the wires use a =
positive/negative=20
voltage scheme.=20
<UL>
<LI>"1" is sent using -10V (or between -5V and -15V).=20
<LI>"0" is sent using +10V (or between 5V and 15V). </LI></UL>So =
an idle=20
line carries something like -10V.=20
<H4>Links</H4>
<UL>
<LI>A nice <A=20
=
href=3D"http://developer.apple.com/documentation/mac/NetworkingOT/graphic=
s/OTSE-L-01.gif">drawing</A>,=20
from this <A=20
=
href=3D"http://developer.apple.com/documentation/mac/NetworkingOT/Network=
ingWOT-79.html">Apple=20
Developer Connection</A> page.=20
<LI>A short <A=20
=
href=3D"http://penguin.dcs.bbk.ac.uk/academic/technology/physical-layer/a=
synchronous/">Asynchronous=20
Communication</A> page=20
<LI>An <A=20
=
href=3D"http://www.taltech.com/TALtech_web/resources/intro-sc.html">Intro=
duction=20
to RS232 Serial Communications</A>=20
<LI><A =
href=3D"http://tldp.org/HOWTO/Serial-HOWTO-20.html">Voltage=20
Waveshapes</A>, part of this huge <A=20
href=3D"http://tldp.org/HOWTO/Serial-HOWTO.html">Serial =
HOWTO</A> <!--<li><a =
href=3D"http://www.erg.abdn.ac.uk/users/gorry/course/phy-pages/async.html=
">here</a></li>--></LI></UL><BR><BR><A=20
href=3D"http://www.fpga4fun.com/SerialInterface2.html"><FONT =
color=3Dblue=20
size=3D2>>>> NEXT: Baud generator=20
>>></FONT></A><BR><BR><BR>
<HR>
This page was last updated on May 10=20
2004.<BR><BR></TD></TR></TBODY></TABLE></BODY></HTML>
------=_NextPart_000_0000_01C66348.19662EC0
Content-Type: image/jpeg
Content-Transfer-Encoding: base64
Content-Location: http://www.fpga4fun.com/images/SerialConnector.jpg
/9j/4AAQSkZJRgABAQEBLAEsAAD/2wBDAAUDBAQEAwUEBAQFBQUGBwwIBwcHBw8LCwkMEQ8SEhEP
ERETFhwXExQaFRERGCEYGh0dHx8fExciJCIeJBweHx7/2wBDAQUFBQcGBw4ICA4eFBEUHh4eHh4e
Hh4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i+F
9dZVF1Jp0O49RIWH6fjRyBc7o/FWzx8ujXRb+JfNXIp0XxV055FjGk3oY9ckcVyv9g2J0h2vXjt7
mFOJIMkSN9DXP6b4a1dmaa51O08tQTGQp3fShREmepP8S7EyhYdLu5R2IIGa1/Cvid9dWR00q4s4
g5QPMfvHnsB7V4za2uti7js/tJikdv8AWCL5VX6+tb2ga74pstNltba/s7vbNgCWIjaucE59eabj
YfkexLcS75FKRFkHBEnBY9AeOP1rF8T+MLHw75aXsE0zshd1t8OYxkDJHBxz6Vn2Wu3qpPcXUttx
wkaLjnp8w6+hzXC6nol/q89xIl5cW082wSySybvOxjkeg4HTHSktQasdRb/GPwnPIkavPFKxwEmA
jOfoxHFa118QNIhtBcoqzLuKt5cqkA5H58HPSvI5Ph/b3Ussmp29jIVJMhdMtKPyrSufBmmtei7K
AC2iVreNRglhjAPY8U+UNT06Xx7oSSSBJlljTGSkiliT220p8caZuYpDI8Y5Lhl6d68g1fwdZn/S
208293L87CIY2E9enWpbPSLFNHSxvbN57eJGQqwbnd3461PKO2h6PcfFXw1Dax3Mko8l+Mh1LD32
+lPb4o+GPLjeOV2VucnA49eeteXWHgvwjp91He2Pg+AIyCNkK7lwRgnB9az9S8C2c7yW8mjwpabh
5XH3QP7vpVKLJ9T27S/H+gareraWMjySBsEnAVSRxzmukaa48zabb5RnBEnP5V83XHwyultXOl3K
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -