Вы находитесь на странице: 1из 80

RS232

1
RS232,
 
p n ( BS250, 2N7000 .), 
RS232, . . (U =20 ) 

RS232 (10 ).

RS232 .

1.2.1.
RS232 RS232

RS232 (. 1.2.1).
1.1.

. 1.2.1.
RS232 
, 
() .
RS232

RS232 (10 12 ) TTL (5 3 ) ,
( [4]).

,
( [4]). 
RS232 , 

.
RS232

.
, 
RS232. , 
, RS232.

1.2. RS232
RS232
( , , 
) , : MAX318X, MAX3190,
ADM3202, MAX1406. , 3 , 
,  
( ADM231L).
SN75155 ( DIP8), 
, .

16 17
RS232 RS232

ADM3202 . Analog Devises 10 2 (. . 2,5 ).


( 460 ); , ,  ( ) 
0,1 ; Vcc=+3 , Vcc=+5 . +3 ( 5
() RS232 10 (Vcc=+5 ) ).
6 (Vcc=+3 ) 5 . ,  
. , ADM3202 1.2.2. RS232
( +3 ).
RS232,
ADM231L 115
, , ,
( , 230 ),
, . 
1,0 .
[4]. 
11,5 V+=+12
, .  (BS250 . Vishay) 
5 . 
(2N7000 . Fairchild Vishay) 
Vcc,
(DG419 . Vishay).
+3 , +5 . .
, .
ADM231L .
MAX1406 . MAXIM ( 230 ),
(11,5 ) 5 , 
Vcc .
3 (V+=+12 , V=12 Vcc=+3+5 ),
( , , , ADM3202
ADM231) .  . 1.2.2.1.
3 3 , , RS232
, (
TO92 (. . 1.2.2.1).
, )  
10 , 200 ,
RS232. MAX1406 
 5060 ,
.
10 , 0,5 . 
RS232 MAX3190 . MAXIM
(U _max) 20 .
( 460 ), 10 
RS232 (, RS232
(. . 2,5 ) V+=+12 V=12 . 
1012 ), RS232.
, 
, ,
.
5 , (), . . 
SOT236 33 .
() MO,
MAX3181 MAX3183 . MAXIM
RS232 5 O.
RS232 ( 1,5 ), 
SOT235 33 . MAX3181 
, 
RS232, MAX3183 , , 
, , RST
( P89LPC9XX).
, ,
SN75155 . Texas Instruments, 8 (DIP8, SOIC8)
, . ,
, .  ) )
(115 ), 2 (V+=+12 , V=12 ), . . 
+5 . . 1.2.2.2.
2N7000 BS250
(, , ADM3202 ADM231L).  RS232: () ()

18 19
RS232 RS232

 2N7000 BS250  . 1.2.2.3 DG419 


RS232  RS232 ( ) 
RS232 (. 1.2.2.2) , (). .
( ) 
, ( )
. 
.

115 200 , ADM3202, ) )
. 
.
***
.1.2.2.3.
DG419 SOIC8 DIP8. DG419
V+, V VL : V+=+10+15 , V=1015 , VL=+3+5 .  RS232: () ()
()
20 .  )
, ( 6). . 1 
1 8 , 1, 8. . 0 

, 2 8 ( 1 8 ).
RS232, , , 
DG419 . Vishay
.
ADG419 . Analog Devices DG419 . MAXIM, [4].
. ,
, (6 ),
ADG419 (Analog Devices) DG419 (MAXIM) 
1.3.
TTL ( . 0 0 +0,8 . 1 +2,4 +5 VL=+5 , V=12 , V+=+12 ).
0 ( 10 )  RS232
, . . , 
( 0 ). DG419 1.3.1.
. Vishay , VL=+5 
U. . 0 V<U.<0,8 , , KIT', 
. 1 +2,4 <U.<V+. V+=+12 , V=12 , U.=10  , 
( RS232) .  . 
, , .
RS232, . , (),
DG419 Vishay (20 ) , RS232, 
DG419 MAXIM (4 ) , ADG419 Analog Devices (35 ). DG419 Vishay .
2 , ADG419 Analog Devices 3 DG419 .
MAXIM. , DG419 Vishay RS232. , :
5 ( 
RS232),   
(), . . ( ;
DG419 ). VL +5 ,  , 
+3 . . ( , . . , 
, DG419 RS232.  , , , , ,
, . . RS232, DG419 ), , ,
( , 30 /). 1015 (  , 
) . ;

20 21
RS232 RS232

  .
, , ,  .
, , , ; ,
 RS232, RS232 ,
 : ,  , , ,
, RST DTR RS232 , ( ), RS232 ,
RTS, ,  .
RST ; (
RS232 . . . ATMEL) , 38 400 , 
. , 
RS232
.
:
, ,
 , , , . , 
(*.exe); 115 200 (,
 , ).
; , , , , .
 RS232 ( 9600 ); 
. ***
, 

, MSC121X (. Texas Instruments),
,
ADUC8XX (. Analog Devices), P89LPC9XX (. Philips semiconductor), AT89C51ED2 (. ATMEL)
.
C8051FXXX (. Silicon Laboratories)
,
. .
 . ,
, (ISP)

RS232 ( C8051FXXX). , ISP 
, ( 
, ,
 !), 
( ), . 
,
( )
, .
RS232 ISP, 
, , , 
, 
RS232, . , 
(,  . .), .
.
, ISP 
( ) 
RS232. , 
, .
ISP . , AT89SXX (. ATMEL) 
. 
ISP SPI; C8051FXXX (. Silicon Laboratories)
, , o ( );
JTAG C2 . . ,
( , 
, 
) .
, (USB, RS232,
. 
). , ,
. . 
.
,
, 3 5 (MSC121X, ADUC8XX,
, .
P89LPC9XX), ISP RS232, 2 ,
,
:
RS232. 
( 2324 ) ( 1024 ).

AT89C51ED2, 
. , ,
, , , 

22 23
RS232 RS232

2 . ,  . ADS1210 . BurrBrown
, . ( . Texas Instruments). 
, , ,  , ,
: (. 2). , ADS1210P 
DIP18 , .
 16 ,
? , , 
 ,
ISP RS232,
 , . .
/ (. . ALE, RD WR), 
, ,
3 5 (. . , ,
( ),
82C54 5 ); , , 
, .
, ( PLCC).
, 50 
AT89C51ED2 (
|120150| ,
).
 (
,
1000 ) (816 ), . . 
RS232.
 
C8051FXXX . Silicon Labortories
, , , , 
( . Cygnal).
 ,
2 : C8051F067 C8051F330D.
( 23 ,
?
 ). ,
C8051F067 16

(SAR, ),
 (. .
( 1 ), 
1000 ,  
. TQFP64 (
100 ).
MSC1210). [4]
,  TQFP64PGA64 .
. C8051F330D 2 
P89LPC9XX 10 , C8051FXXX, DIP(20 24), 
, , , . . , . , 10 ,
. ( 16). (, ,
. DIP14 (C8051F300P), 8 ,
MSC12XX , .)
( 1415 ) 100 , . .   ISP: C8051F067 JTAG, C8051F330D
10 . C2. USBDEBUG.
( 25 ). , 
  . , 
25 . ,  (datasheet). .
, 0,1 , 816, . , ISP  USBDEBUG
ADUC8XX ( ( 2000 .).
7080 ).  , C8051F067 
. MSC12XX ADUC8XX / ( ALE, WR RD) 
. ( 82C54).
, (816 ),  
, , 0,1 ?  , ( 
: , 12 ).
 1000 , , ,
. 5 ( 82C54 ),

24 25
RS232 RS232

. . 2,73,6 .  , 
C8051FXX . ( 
+3 +5 ( ADG3300 . Analog Devices). ) , 
, , SAR . .
: (  
, LC RC)  C8051FXX RS232 ,
( . 
; (Application) JTAG (C8051F067) C2 (C8051F330)
(. www.silabs.com). USBDEBUG. , , 
, ,  RS232, 
 . , , RS232 TxD RxD 
(  C8051F330D C8051F067. , ,
2 RS232). . . , ,
 ( ), ( , , 
C8051FXXX /,  ) (5560 .) USB
. , , , 2 / DEBUG.
RS232 (p0.0TxD, p0.1RxD C8051F067 p0.4TxD, p0.5RxD 
C8051F330D), . . , TxD  1.3.2.
( , RS232
RXD ). RS232 (ISP) 
( SBUF). (. . 0
. 
1 ( RS232). 
(RESETRST).
, , , , 
( , )
TxD ( , , ) RxD. 
(RST),
,
. RST 
( ) RS232
, . . RST . 1, 
, . , 
. RST . 0 .
, 
MSC121X, ADUC8XX AT89C51ED2(RD2) RST
DTRDSR RTSCTS, TxD RxD (
, . . .
[4] 
P89LPC9XX C8051FXXX , RST
). .
, TxD (. . 0 1)  , . . RST . 0 
RS232. , . 1 .
, , , RST , ,
, TxD,  . . , . , RST 
( ). , 
 O, (
( XonXoff). ). , ,
: TQFP64 . MSC12XX 500 O, ADUC8XX 100 O. RST 
,  , . 
MSC12XX, .  , P89LPC9XX , 
64 , 0,5 , , 20 O.
0,3 ! ,  .  , RST , 
, ,  ,
.  ( ()
PLCC68 (, , AT89C51ED2). push pull).

26 27
RS232 RS232

, RST .  3fch 0, DTR RTS , . .


, ,  . 0 (e) 10 . , , 3fch
. , : DTR=+10 , RTS=10 .
ISP ( RS232)  DTR RS , . .
,  DTR=RTS=10 .
. , RST PSEN MSC12XX, ADUC8XX
, RST (. . ISP AT89C51ED2(RD2) RST Vdd P89LPC9XX
). C8051FXXX ( RST) ( ) DTR RTS.
MSC12XX, ADUC8XX AT89C51ED2(RD2) ,
PSEN, ( ) ,
. PSEN , , . . PSEN MSC12XX, ADUC8XX AT89C51ED2 . 1
. ( ), ( Vdd) P89LPC9XX
PSEN  ( ).
10 O, . PSEN RST DTR (. . 
, ), PSEN Vdd 
( , RTS.
, . . . 0 , , 3fch
12 . 1, ). . , RST, PSEN Vdd 
. 0 1 O, ( , , :
. . 1 PSEN 00; 01; 10 11, 0; 1; 2 3).
(, ),  , 
.  RS232 .
( 1 )  1. RS232 ( DTR RS , . .
PSEN 10100 O,  10 ) 
(, , 1 ). (RST MSC12XX, ADUC8XX AT89C51ED2(RD2)
10 O. MSC12XX, ADUC8XX . 1, . . (3 5 ), RST
AT89C51ED2(RD2) ISP PSEN . 0.  P89LPC9XX C8051FXXX . 0, . .
PSEN . 1.
0 .
P89LPC9XX ,
, PSEN MSC12XX, ADUC8XX
, Vdd.
AT89C51ED2(RD2) . 1, . ., ,
, ( 
10 , ( Vdd)
3 ), ,
P89LPC9XX . 
(
. 
), (). , 
.

2. DTR
( ), 
. 1 (+10 ). RST
( 3 ). KMO
MSC12XX, ADUC8XX AT89C51ED2(RD2)
(, BS250 2N7000, ). 
. 0 (0 ), RST P89LPC9XX C8051FXXX 
DG419.
. 1 (+3 ). , PSEN MSC12XX,
C8051FXX RS232
ADUC8XX AT89C51ED2(RD2) . 1, . .
ISP ( : C2 JTAG),
10 , 
RS232 RST .
P89LPC9XX (Vdd=+3 ).
RS232 .
3. , DTR RTS,
(. 1), RS232 ( COM 1)
. 1 ( ).
2 (DTR RTS),
, 3fch. 0 4. 
DTR, 1 RTS. , , DTR RTS. ,

28 29
RS232 RS232

, RST, PSEN Vdd  (. 1.3.3.1,) , RS232 


 , .
ISP, . . . 1.3.3.2 PSEN.
 () , . . PSEN, , 
. ; , . 
ISP , , , PSEN ( ) 
(. 1). 10 O, DG419.
,  () , , . . 100 O 
DTR RTS  . . 14 (1.3.2).
,
4 . 1.3.4. RST Vdd
P89LPC9XX C8051FXXX
1.3.3. RST PSEN . 1.3.4.1
MSC12XX, ADUC8XX AT8951ED2(RD2) RST ( P89LPC9XX C8051FXXX), . 1.3.4.2
Vdd P89LPC9XX. 
. 1.3.3.1. , .
RST

DG419 RS232 . 1.3.4.1.
 RST


, 
ISP.
. 1.3.3.1, 2 

RST, . 1.3.3.2
2 
PSEN 
. 1.3.3.2. MSC12XX, ADUC8XX
AT89C51ED2(RD2).  . 1.3.4.2.
RSEN (. 1.3.4.1,)
Vdd
 (2N7000)
,  (BS250) 
 , ,
. , 3 (
. 1.3.3.1, R1
 ).
RST DTR.  , 
,  .
RST . 14 (. (. 1.3.4.1,) 
. 1.3.2) DTR  ,
, . . 
RS232, (RST) , .
 , . 1.3.4.2,, , 
. ,  , ( 10 ), 
 , . . R2 ( Vdd 
. ) 3 . R2

30 31
RS232 RS232

; ,
3 . . 1.3.5.1.
MSC12XX
, ;  RS232 !
( ISP
KO), , ,
1.
(. 1.3.4.2,) , . .
(Vdd)
( ISP).
Vdd ( ,
RST).
, . 1.3.4.2,, , 
.
. (20 ) ,
(. 1.3.4.2,).
, .
***
, 
RST, PSEN Vdd (, , ), 
, , , 
, 
, ISP.
.

1.3.5. MSC12XX

MSC12XX
RS232 ISP (. 1.3.5.1).
, RST RS232 (1312
ADM3202), DTR, 
PSEN DG419, (6 )
RTS. RST PSEN . 1.3.5.1
(. . 1.3.3.1, 1.3.3.2, ) , .
RS232
IDC10P (X1).
2 (P1),
+3,3 . (LD1 R5).
Z1, 
C6 C7. EA 
R4.
, (. 1.3.5.1) ( 
, 
RS232).
. 1.3.5.1 6 IDC6P (X2),
+3,3 , : VddT, RSTT, PDA PCL, 

32 33
RS232 RS232

P1.0, P1.1, P1.2 P1.3 . 1.3.6. ADUC8XX



P89LPC9XX (ICP)
MSC1210. . (1.3.7). ADUC8XX
(. 1.3.5.1) (. 1.3.5.2). RS232 ISP (. 1.3.6.1). ,
MSC1210  ( e [4], a . 1.3.6.1.
. 1.3.5.3), PGA64. , , !
PGA64 ( ADUC8XX
RS232 ISP
),  ADUC847.
IDC6 (X2 . 1.3.5.1) ICP
89LPC9XX (. 1.3.5.2) .

. 1.3.5.2.




MSC1210

. 1.3.5.3.
!


MSC1210 ( TQFP64)

34 35
RS232 RS232

RST PSEN . 1.3.6.4.


ADUC8XX MSC12XX, !
. ,

. ADUC834
. 1.3.6.2 ( . 1.3.5.2), 
 ADUC847; 
ADUC847 . 1.3.6.3, ADUC834
. 1.3.6.4.

. 1.3.6.2.


ADUC847

1.3.7. AT89C51ED2(RD2)

. 1.3.7.1
AT89C51ED2/RD2 RS232 ISP
, RST PSEN 
. 1.3.6.3. MSC12XX, . 
,
!
.
ADUC847 AT89C51ED2 
RS232 ISP
. 39 (. 1.3.7.2).

1.3.8. P89LPC9XX

P89LPC9XX 23
(20022003 .) . 
, (, P89LPC93XX) 2
(ISP): 1 RS232 (
ISP), 2 2 
C2.
ICP InCircuitProgramming ( 
). 2 : PDA DATA ( 
) PCL CLock (, ).  

36 37
RS232 RS232

. 1.3.7.2
. 1.3.7.1.
!
!
AT89C51ED2/RD2
AT89C51ED2
RS232
! RS232
ISP ISP

 , P89LPC90X , 
, : 
(2 ); 10 (P89LPC904); 
24 ;
: , ()
; ,
( SOIC ) ( LP Low Power
).
 , P89LPC9XX, 
RS232 ISP, o (C2), 
, 
ICP ,
ISP (. ICP ISP P89LPC9XX).
  ( ),
SPI ( , SPI (MISO) (MOSI)  P89LPC9XX ICP ,
) UART 51  RS232 ( P89LPC938 MSC1210), 
. (C2) P89LPC9XX
( P89LPC932). , RS232 .
ADUC8XX MSC12XX , [4]. 
 , 
. C8051FXX ( DTRDSR RTSCTS ( ), 
C8051F330) . Silicon Laboratories ( ). TxD RxD. XONXOFF
(8) . Philips (P89LPC90X) ( TxD RxD) 
ICP, . . (C2).  . 
RS232, , (, 115 200 ).
P89LPC9XX ICP 3 . RS232 

38 39
RS232 RS232

 Vdd RTS, 
(DTRDSR RTSCTS).  (1). T1 Vdd
 . 2
: ,  RST Vdd (. . 1.3.4.1, 1.3.4.2,),  
.
(. 1.3.2, ADM231L 
. 14), ,  TXDM RXDM TxD RxD 
, , DSR RS232. ADM231L (V+) 
, +12 ; Vcc +3,3 . 
. o (RxD DSR) 11,5 ,
6 (!) (TxDM) (0+3,3 ).
, . . RXDM 0+3,3 TxD RS232
, 2  10 . ADM231L
( ). 230 , 115 200 .
+3,3
RS232 ( LP2950Z3.3 (DA1).
), P89LPC9XX ICP
 P89LPC938 6 IDC6 (X2),
; PDA PCL ( ), VddT,
/ Vdd 
. , RSTT, RST. 4 (PDA, PCL,
(TxD RxD) VddT RSTT) P89LPC938 (DD2).
, X2 (+3,3 , 3) 
( . . )  ( 1).
,  P89LPC904 (DD3), 
, P89LPC938 (DD2). 

.  RS232. P89LPC938 (DD2) PLCC28, 
[4]; P89LPC904 DIP8. RS232
, IDC10 (X1).
,  P89LPC938 P89LPC904 C2
,  (. 1.3.8.2), ICP,
TxD RxD. , C2 (PCL, PDA, RSTT), (+3,3 )
3 IDC6P (X1), 

(. 1.3.8.1 1.3.8.2). . 1.3.8.2.
ICP
P89LPC938 !
P89LPC93X
RS232 (. 1.3.8.1),  P89LPC90X
. 1.3.8.1. RST
P89LPC938
RS232
DTR, ,
ISP . ADM231L (DD1,
( P89LPC938 9,10), 

P89LPC9XX ICP ( ICP)
BS250 (T2).
RST 
P89LPC938 (DD2).

40 41
RS232 RS232

P89LPC938 P89LPC904, (PLCC28 DIP8 


). / (VddT) 5 X1
 BS250 (T1). 
Vdd, 
. .
ISP ICP (. 1.3.8.3)
6 1015 , IDC6M. . 1.3.8.5.
ISP
. 1.3.8.3.
MSC12XX,
ISP ICP
ICP !
P89LPC9XX
( !
. 1.3.8.4 , ,
)
. . ICP P89LPC9XX 
ISP P89LPC93X,
. , , 
MSC12XX,
P89LPC9XX, , , ,
MSC1210 IDC6P (X2 . 1.3.5.1)  1.3.9. C8051FXXX
MSC1210 (. . 1.3.5.1).
( . 1.3.8.3).
ISP (. 1.3.8.1) . C8051F067 C8051F330D 
ISP (. 1.3.9.1) USBDEBUG
, C8051F067 JTAG,
C8051F330D C2. USBDEBUG
USB. ,
RS232,
.
. 1.3.8.4.
: USBDEBUG 
ICP ! .
P89LPC93X 10 IDC10P X2(JTAG/C2),
P89LPC90X;
ISP ! IDC10M,
USBDEBUG . X2(JTAG/C2) USBDEBUG
P89LPC93X : TCK/C2DAT (4 ), TMS (5 ), TDO
(
.) (6 ) TDI/C2CK (7 ). 2, 3 9 , 1, 8 10
) )
.
3 : P1, P2 P3, 
. 1.3.8.5 ISP MSC12XX,  (, 
ICP P89LPC9XX . ), USBDEBUG.
ISP ICP  23 3 (P1, P2 P3)
P89LPC9XX. ,  JTAG, 
MSC1210 (  C8051F067. TCK/C2DAT X2(JTAG/C2) 
RS232 ), () TCK67, TMS TMS67 TDI/C2CK TDI67. 
P89LPC9XX ICP  , TCK67 R5.
. , TDO X2(JTAG/C2) ( )
() TDO67.

42 43
RS232 RS232

() RSTM. RSTM RST/C2CK 


C8051F330D RST C8051F067.
, C8051F330D ( 12
P1, P2 P3) TDI/C2CK X2(JTAGC2) RST/C2CK
C8051F330D. C8051F067 (
23 P1, P2 P3) RST 
R4 (
).
1 2 P4
. RST
RSTM RESET ( RST C8051F067
RST/C2K C8051F330D). , RST 
 1 (2N7000) DTR RS232
RS232 (9 10 ADM231LDD1) ( 
RST (. . 1.3.4.1,), 2N7000).
USBDEBUG (. .
IDC10M IDC10P X2(JTAG/C2), 
.
USBDEBUG (IDE) (Disconnect).
JTAG C2 USBDEBUG
, (IDE) .
, (. 1.3.9.1)
: C8051F067, C8051F330D. ,
(
) RS232 JTAG/C2.
.
, USBDEBUG RS232 COM
.
RS232
. (. 1.3.9.1) 
. 1.3.9.1 TCK67, TMS67, TDI67 TDO67 TCK, TMS, , . 

! TDI TDO C8051F067. USB .
C8051F067 DEBUG C8051F067. TxD RS232
C8051F330D 12 3 (P1, P2 P3)  ADM231L (DD1) 5 6.

! C2,  RXDM, RS232
C8051F330D. 2 (TCK/C2DAT TDO),  P0.1/RxD0 P0.5/RxD C8051F067 C8051F330D.
ISP X2(JTAG/C2) 2 P1 P2,  , (. . 
R3 C2D. (C2D)  ) . 
P2.0/C2D C8051F330D. TDI/C2CK,  (. . ) 
X2(JTAG/C2) 2 P3, () .
RST/C2CLK. , , , C8051XXX
( , ,
/ ) 3 P4,  , (). 
. TxD , 
2 3 P4 RS232 (a UARTenable) TxD 
. RST/C2CLK, P3 P4, . , (TXD=0 TXD=1) 

44 45
RS232 RS232

(setb TxD clr TxD) : 2 (2) ( SN74HC08)


. 1. TxD , DIP 2 . 
 ( A) RS232 ( SBUF=0x41, , , ( )
mov SBUF, #41h). Cygnal. SN74HC132, (. 1.3.9.1).
, RS232 LD1. 
. RxD (. 1 . 0), +12 , P5 
(  ADM231L. 
) RxD  +3,3 , LP2950Z3.3 (DA1). 
( DSR). , DSR,  C8051F067 (+3,3 ) (+3,3)
RxD. , R6 0 .
 R7 
RS232 ( . . . 1.3.9.1), , TxDM  .
2 RS232 (7, 4 8, 11 , , .
D1), RxD, (. 1.3.9.1) 
DSR). RxD. ,  .
RxD C8051FXXX, , ,
, UART . . C8051F330 DIP24. C8051F330P. 
, TxD C8051F330D (DIP20) 
( C8051FXXX). (. 1.3.9.2). 4
,  C8051F330P (NC).
. , TxD 
. 1.3.9.2

()
(. 1). (. 0),
C8051F330P
; (. 1). 
, ( ) .
TxD*, , 2
, : . 1
TxD (. . ), TxD*,
TxD*. ,
. 1 TxD* TxD 2
TxD (. . 
). C8051F067
, 2 ,  C8051F330D (. 1.3.9.3) 3
() , () 2 . (P1, P2 P3 ), JTAGC2,
. 1.3.9.1 , , 2 3 P4, : 
74AHC1G08. /. C8051F330P (DIP24), 
2 ,  C8051F330D (DIP20). ,
TxD (TxD067 TxD330), TxD* (Tx0067 Tx0330),  . DIP24.
C8051F067 C8051F330D. TxD067 C8051F330D (DIP20) DIP24 , 1
P0.0/TxD0, Tx0067 P0.2  2 , . .
C8051F067. TxD330 P0.4/TxD Tx0330 . ,
P1.7 C8051F330D. 2 TxDM, (. 1.3.9.1).
C8051F067 PGA64.
ADM231L (DD1). . 1.3.9.4  TQFP64PGA64
, , , C8051F067.
74AHC1G08, . . SOT235. 

46 47
RS232 RS232

. 1.3.9.3.
. 1.3.10.



C8051F067
C8051F330D

1.4. RS232
. 1.3.9.4
! RS232 ,
, ( ) 
TQFP64!PGA64 .

C8051F067 , , ,
, 
, ( RS232).
, ( 
) , RS232 
, , ,
.
, ,
. 
, ( 
), ,
RS232.
,
RS232
, . , , 
( ), 
RS232 . 
(,
, 5000
1.3.10. ), (
5 MSC12XX (. 1.3.5.1), ADUC8XX , , , 
(. 1.3.6.1), P89LPC93X (. 1.3.7.1), AT89C51ED2 (. 1.3.8.1) C8051F067/330D (. ).
1.3.9.1) RS232  . ,
(. 1.3.10), 10 ( ), 
11,5 , 10 IDC10M . , ( 
9 DB9M, ) , , .
COM (RS232). 5 
. . , , 

48 49
RS232 RS232

, ,  SN75155); , 
( ),  RS232 ( ) , 
, . .  RS232. 
, ( RS232 . ,
ISO150 . BurrBrown (TI) 15 .).
, , . DCDC. (
. Analog Devices.  RS232) :
iCoupler.  (ADUM120X)   , RxD 
, , ,  10 , . . 
ISO150 . BurrBrown (TI). ADUM120X  ;
, .   1015 ;
, 0 25 (!),  , RS232;
0,1 ( 115 ) 10(!)  ,
, 6N137. (. . ,
) ( , Windows;
, ) . ,  , . .
1 . , SOIC, RS232;
. , 2  ,
2 ADUM1201AR (01 M, 2,5 .) SOIC8 .
551 . , , 
RS232
(, , ,
DCDC ADUM120X ,
). .
. 
, , , 
 DIP ,
TTL
,
RS232 (, , ). , , . .
, (
RS232 (., , 1.2.1 1.2.2). , 
).
, (,
, RST, PSEN . .),
1.4.1. RS232
.
ADUM1201,
[4] ,
SN75155
RS232, , 
DCDC. (2003 .) (
DCDC DCDC MSC12XX, ADUC8XX AT89C51ED2/RD2) 
DCP05XX DCR05XX 12 . BurrBrown (TI)  RS232 (. 1.4.1.1).
1011 . (, ). 
.  ADUM1201 (DD2) ,
H11L1 (DD3) TLP521 (DD4). ,
RS232, . . . , , ( ) 
SN75155 (DD1) . Texas Instruments. 
, ( ). 12 , 11
DCDC  SN75155. DCDC
. DCDC,  RQD0512 (DD5) . Recom 1 , 
(!) , DCR05XX DCP05XX, +5 2 : +12 12 , 42 
2 . DCDC RSDXX (. . ,
RQDXX 0,251,0 . Recom . DCDC ). ;
RS232 ( RS232 (TxDM RxDM) (RST PSEN).

50 51
RS232 RS232

. 1.4.1.2.
!
SOIC8DIP8
ADUM1201 (
,
)

. 1.4.1.1.


RS232

ADUM1201


SN75155


MSC12XX, ADUC8XX
AT89C51ED2(RD2)

 , 
40 0,50,7 .
( )  (
), . , 1 

. 1.4.1.3.
!
SOIC8DIP8
ADUM1201:
;


, ,
. RxD DSR DB9M,
COM . , SN75155
(2 7 ) 2 ( 2 RS232).
+5 ( ADUM1201) 
LP2950CZ5.0 (DD6).
115 200 
15 .
ADUM1201 SOIC8, 
. 
 SOIC8DIP8, 
. 1.4.1.2. ) )

52 53
RS232 RS232

, ; 
 .
, (), 
,  (
1 8 ) DIP 0,3 , 7,62 . 
, ,
6 . ,
, SOIC8
( 1 8 ) 6,2 . 
SOIC8  , . 1.4.1.2
( ).
(. 1.4.1.3), 
 , 
. , , , . 1.4.2.1.
, , 

, , QFN.
, ADUM1201, ADUM1200
, .
ADM3202
 SOIC8DIP8 ADUM1201 (. 1.4.1.3),
, ADUM1201 ( )  MSC12XX,
, , 1 , ADUC8XX
AT89C51ED2(RD2)
( ).

1.4.2. RS232
ADUM1201, ADUM1200
ADM3202 MAX3181
RS232 2 
ADUM1201(DD2), ADUM1200(DD3) ADM3202(DD1)
MAX3181(DD5) (. 1.4.2.1), (. . 1.4.1.1), 4
TxDM, RxDM, RST PSEN 
MSC12XX, ADUC8XX AT89C51ED2 (RD2),  , ADUM1201
. ADUM1200,  2SOIC8DIP12, 
, ADM3202 2 (10, 7 11, 14 . 1.4.2.2. 
DD1), RxD DSR .  , ,
, . . 1 .  SOIC8DIP8, . . , . 1.4.1.3.
, . , RS232 MAX3181 (DD5 . 1.4.2.1)
RxD DSR ,  SOT235, , SOIC8, ,
ADM3202 (RxDa),  SOT236DIP6 SOIC8DIP8
ADUM1201 (2, 7 DD2). ,  (. 1.4.1.2), .  
( ,  MAX3181 
),  .
+5 ( +5 A), DCDC RQS0505  . 1.4.2.3 2 :
0,25 . DCDC RQS0505 ( )  2SOIC8DIP12 SOT236DIP6.
RQD0512, (. 1.4.1.1). ,  , , MAX3181
+5 (DD6 . . 1.4.1.1). ( ),  2N7000.

54 55
RS232 RS232

. 1.4.2.2. 1.4.3. RS232


! ADUM1201, ADUM1200
2SOIC8DIP12 MAX1406
ADUM1201 ADUM1200
RS232 ADUM1201
ADUM1200 (. 1.4.3) , (. 1.2.4.1), . . 
MAX1406 (DD1),
.
(MAX3181), . 1.4.2.1. , 
+5 (DD5 LP2950Z5.0) , , 
DCDC (+12 12 )
(DD4 RQD0512).
115 200 ( , 
MAX1406 230 ). 
11,5 5 , 
MAX1406 ADM3202 ( 10

. 1.4.2.3.
!

2SOIC8DIP12

ADUM1201
ADUM1200 ()
SOT!23!6DIP6 ()
MAX3181

. 1.4.3.



ADUM1201, ADUM1200

) MAX1406
) !

MAX3181 2N7000  MSC12XX, ADUC8XX
, , . 1.4.2.1.  AT89C51ED2(RD2)
(. 1.4.2.1). , 
( ) (
MAX3181). ,
115 200 , . . ADM3202 MAX3181 
460 1,5 . 
20 .
(
MSC12XX, ADUM8XX AT89C51ED2/RD2).

56 57
RS232 RS232

+5 ). ( ) 20 .
, , 
(. 1.4.2.1), MAX1406 DIP16 (MAX1406CPE).
, ( ) 
5 .
, MAX1406. 
. MAXIM
MC145406 . Motorola SN75C1406 . Texas Instruments ,  . 1.4.4.1.1.

( 115 200 ), MC145406, SN75C1406 !
. !
2 ADUMAX
ADUM1201, ADUM1200,
RS232 ( . 1.4.3). ,  MAX3181 MAX3190
, , 38 400 ; 
, 2 ,
.

1.4.4. RS232
ADUM1201, ADUM1200
MAX3190 MAX3181
ADUM1201 ADUM1200 
MAX3190, MAX3181 MAX3183 

RS232,
DIP. , , DIP
,  DIP,  . 1.4.4.1.2.
, , , 

, .  ADUMAX ADUM1201, ADUM1200, MAX3181
. MAX3190
2
, 
MSC12XX, ADUC8XX 89C51ED2(RD2) (1 ) 
P89LPC9XX (2 ), ( ) 
C8051F067/330D.

1.4.4.1.
ADUM1201, ADUM1200, MAX3181
MAX3190 MSC12XX,
ADUC8XX AT89C51ED2/RD2 MAX3190 (DD3) MAX3181 (DD4),
( ) 2 MAX1200 (DD2)
ADUM1201, ADUM1200, MAX3181 MAX3190 (. 1.4.4.1.1) 3 MAX3181 (DD5 DD6).
RS232 MAX3181 (DD4, DD5 DD6), ADUMAX (. 1.4.4.1.3) , 
RS232 MAX3190 (DD3), 2 ADUM1201 6 , 5 14 
(DD1) 2 ADUM1200 (DD2).  , , , 
ADUMAX. DIP16. (. 1.4.4.1.3,)
(. 1.4.4.1.2) .  ( ) , 1 
( ) a ADUM1201 (DD1) ADUMAX, .

58 59
RS232 RS232

ADUMAX
MSC12XX, ADUC8XX AT89C51ED2 (RD2), . 1.4.4.1.4,
RxDM, RST PSEN RS232 TxD, DTR RTS
, RxD
TxDM. . 
115 200 . 
20 . , ,
.
.

1.4.4.2.
)
ADUM1201, ADUM1200, MAX3181, MAX3183
. 1.4.4.1.3. MAX3190 P89LPC9XX
!
ADUMAX ADUM1201, ADUM1200, ADUM1201,
MAX3181 MAX3190: ; ADUM1200, MAX3181, MAX3183 MAX3190, . 1.4.4.2.1, 
)
ADUMAX1. , ADUMAX1 ADUMAX (. 1.4.4.1.1)
, 2 ADUMAX MAX3181(DD5 DD6)
2 MAX3183 (e DD5 DD6). 
. 1.4.4.1.4.
.
ADUMAX1
ADUMAX ! P89LPC9XX (. 1.4.4.2.2) RxDM, RST Vcc 
MSC12XX,
ADUC8XX 89C51ED2 (RD2)
RS232 TxD, DTR RTS , RxD 

. 1.4.4.2.1.



ADUMAX1 ADUM1201,
ADUM1200, MAX3181, MAX3183
MAX3190

60 61
RS232 , RS232 20 ?

TxDM. Vcc  1.5. ,


BS250 (T1), +3,3 ,  RS232 20 ?
 ADUMAX1 ( 10 16).
RTS RS232. . RS232; 
115 200 .  , ,
20 . , , , ,
. RS232. 
.  . ,
, ,
C8051F067/330D ( RTS T1).
(. 1.5.1).
.
( ), 
RS232 TxD RxD , , SG.
RS232 
( RS232), . . 
. 1.4.4.2.2. ( 
).
ADUMAX1 !
P89LPC9XX , 
, (). 
, 1 ( 900 ) 
. , ,
, ;

. 1.5.1.
!
RS232RS485/RS422

62 63
RS232 , RS232 20 ?

 , . . 
.  . 1.5.4.
RS232 RS485 , 
RS485 ,

. RS232RS485/RS422

RS485/RS422TTL(ADM488), , 
RS232 ADM3202 (. 1.5.1). , 
(K01K08). 
VD1. 
+5 /200 .
() 
(, ) . 1.5.2 . DIP 
. 
( 9 ).


. 1.5.2.



RS232RS485/RS422:
;
;

( )

. 1.5.3.


RS232RS485/RS422

(. 1.5.3) , 
8 , 
. ,
.
2 RS232RS485/RS422
(. 1.5.4) : , 
( DB9M,
COM ), .

64 65
RS232

. 1.5.5.

!


RS232RS485/RS422

(. 1.5.5) 
() 4 11,5 .
,
2 .


115 200 1 (!). RS232

2.1. ............................................................68
2.2. 
...........................................................................71
2.3.
a ...............................................75
2.4.
RS232 ..................83
2.5. RS232 Windows98/XP .....125
2.6. RS232
(In_System_ProgrammingISP) .....161

2
, , 
Win98,SE2.
 Win'XP, SP2 (Win'2000, Win'Me .),
Win98, , . . 
, 
. , 
. Win'XP, SP2,
, Win'NT, Win'2000, Win'Me .
.
Win'XP ,
RS232 
. Win'XP DOS.
: / .
, ( 
2.1. a USERPORT, Win'XP
RS232,  /), Win'XP
, .  , , / 
, ,  . Win'XP .
. Win'98, SE2 , . .
,  DOS, , 
. , () DOS, .
Windows. Windows Win'XP;
DOS (MSDOS V7.0) , Win'98 , , DOS
Windows . Windows .  Win'XP, Win'XP Windows. ,
Windows98 2 (Win'98, SE2) WindowsXP DOS . ,
2 WindowsXP professional, service pack 2 DOS , , 
(Win'XP, SP2). Windows, Win'98, SE2 , DOS, ,
(WindowsV3.1, Windows95) Win'XP, SP2 (Windows2000, WindowsM .), RS232 Win'XP
WindowsNT, ,  DOS ( Win'XP 
. / : in out).
Windows98, SE2 . Win'XP ( , Win'98) RS232 
Win'98 o , ( ),
( )  Microsoft (Application Programm Interface API).
DOS. DOS Win'98 API , API .
, ( DOS7.0). Win'98 , , , 
, , (, ),
,  RS232 MSDN ( http://msdn.microsoft.com/library )
, .  API.
Win'98 DOS,  , RS232 Windows
( , ). Win'98 API. , , API, Win'98,
, / .  RS232, API,
RS232  RS232.
DOS. , , ,  . 
. ,
Windows 3.1 , DOS, RS232 DOS (Clarion v3.101)
. Windows'95 ,  [4],

68 69
RS232 

, Win'XP, P89LPC9XX 
Windows. ( 2005 .) ICP, .
Clarion v6.0. , 
DOS Clarion DOS (ClarionV3.101)  . : , 
(Graphic User DOS Windows; 
Interface) GUI3. ( )
(CKeil, ( );
v6.14),  RS232 ( ); API
. RS232 Windows 
, ;
RS232 ( ),  / (in out) Win'XP
, ( RS232 DOS, Win'98
). Win'XP.
( DOS Windows)  (ISP) 
(, , )  MSC12XX, ADUC8XX, AT89C51ED2(RD2) P89LPC93XX
( ).  RS232. MSC12XX, ADUC8XX P89LPC93XX
, . .  DOS Win'XP.
( ) .  AT89C51ED2(RD2) ,
. . ATMEL (ISP)
. FLIP V.2.4.4. 
, , .
. P89LPC9XX
, (USHORT unsigned short ) ICP (P89LPC93X MSC12XX)
(BYTE unsigned char )  , , P89LPC93X MSC12XX,
. 8 DOS Win'XP,
( RS232) ; P89LPC9XX, , ,
, ( C8051FXXX JTAG C2 ( USBDEBUG)
), .  RS232.
, 
2 1 ( ).
, , 2.2. 
,
. , . .
, 2.2.1.
.
 , 
RS232, ,  , RS232
1 [4]. . 
,  DOS
, ,  Windows. DOS, , , 
, , , Windows
.  .
, , DOS Windows. 
.  DOS, Windows.
,  , , , 
. ,  , , DOS

70 71
RS232 

DOS ( Clarion v.3.100), Windows 2. , 1 2 . , , 10 ,


Windows ( (2005 .) 5:
Clarion v.6.0).
!
2.2.2. - ! 10 .
DOS !
loop i#=1 to 5
Clarion v.3.100 DOS () . : .
(Static Model), (Overlay Model) (Protected Mode). !
, , ,
, , , , 
. . , , 10
, . . . , 10 . , 
(DOS Extender). (, , 
. , , ).
, . ,
, , 2.2.3. -
. Windows
18 , 
Windows 
(530 ) . 
. , Win'98 Win'XP
. ,

 N (, 
QueryPerformanceCounter, 
), 
F QueryPerformanceFrequency. Win'98 Win'XP
, , . . . N 
2 M Win'98 7 Win'XP ( P4, 1,7
, F[1/c]. ,
). . 
. 
F 
, , , DOS . 
. 1 000 000,
.
1 . , 25, 
( 10 ) , i .
, 25 .
.
, . . 
(Win'98 Win'XP).
!
! 8 , ,
! . , ,
! 0ffffffffffffffffh=18 446 744 073 709 551 615. , 
T#=clock() , , . 
i#=0 8 , (COUNTER)
loop 4 (ULONG LONG), (GROUP).
if (clock()T#)>1000 then break. (FREQUENCY). 
i#=i#+1 , . 
. .
show(10,10,'10 .=')
API ( 
setcursor(10,20)
type(i#)
). API 
! . , :

10 i#.  QueryPerformanceCounter(*STRING),BOOL,RAW,PASCAL
, , , i#=20000000. , i# 10 000 000 (10 = 10 000 000 ),
72 73
RS232

, Clarion v.6.0,  !
25 .
do DEL25 ! 25 .

do DEL25 ! 
! 
! 
25 : !
!
! !
PROGRAM ! 
! ! 
! ! 
! !
FREQUENCY GROUP,PRE(FRE) DEL25 routine
FREQL ULONG loop until QueryPerformanceCounter(COUNTER). ! .
FREQH LONG CSTARTL=CNT:COUNTL !
. CSTARTH=CNT:COUNTH ! long.
COUNTER GROUP,PRE(CNT) loop
COUNTL ULONG loop until QueryPerformanceCounter(COUNTER). !
COUNTH LONG if CNT:COUNTH=CSTARTH !
. DELTAC=CNT:COUNTLCSTARTL !
! lse !
DELTAC=0ffffffffffffffffhCSTARTL+CNT:COUNTL+1 !
. !
! if DELTAC>DC then break. ! DC(=25 .)
! API WIN'XP. . !
! !

!
MODULE('DELAY')
QueryPerformanceCounter(*STRING),BOOL,RAW,PASCAL
QueryPerformanceFrequency(*STRING),BOOL,RAW,PASCAL
2.3.
END

! , 
!  . ,
!  2 (
CODE
USHORT / unsigned short ) 1 ( BYTE
! 
! 
unsigned char ).
.
! RS232
! 25 .  , N . N
! (, N ).
loop until QueryPerformanceFrequency(FREQUENCY). ! N 2, USHORT. , USHORT
! . 8 (1) (RS232), 
DC=int(25*FRE:FREQL/1000000) ! 25 . 1 ( BYTE), , ,
! (NH) (NL) N. , ,
!  NL, NH. 2 
! 
1 (NL NH) 2 N

74 75
RS232

, , 
. .
BT RS232
. 

2 N 1 NH NL.
!
, , :
N 
NH=int(N/256) :
NL=N256*NH
//
T. e. NH N 256, NL //
N , 256. //
NH NL N. unsigned char NL,NH;
, , : unsigned int N;
//
N=NH*256+NL // /
//
unsigned char inbyte() {
. . N NH, 
.
256, . RS232
.
N=35000 return(byte);
. }
//
!
PROGRAM //
//
N USHORT ! N //
NH BYTE ! N void main(void) {
NL BYTE ! N NH=inbyte();
BT BYTE ! / NL=inbyte();
N=NH*256+NL;
CODE }
//
N=35000
, N RS232,
NH=int(N/256) ee NH NL,
NL=NNH
NL NH. .
, . .
BT=NH
do OUTBYTE , 
BT=NL . 
do OUTBYTE , , . .
. , , 
return , .
! ,
! , ( ). 
! , ( 
OUTBYTE routine

76 77
RS232

, ) . ,  . . ; , 
 N, NH NL 2 ( 4, 
. ), . . 2 . 
, , ? , .
. .
, . .
.
// , RS232 S,
// "u.N" "u.bt.NL" "u.bt.NH". N .
// u.N ( ushort) , 
// u.bt.NL u.bt.NH ( byte(unsigned char)) . , 
// . , , . . 
// NH() NL()
.
// (struct)
, . , ,
// !!!
//
, , :
union{ . , ,
unsigned short N; // ("u.N"). . S 
struct{ , N. ( ) 
unsigned char NH; // . ("u.bt.NH"). ( N = 75):
unsigned char NL; // . ("u.bt.NL").
}bt; S string(75)
}u; M byte,dim(75),over(S)
//
over (S) . ,
// 75 S 75 
// / ( 75 ). , M[1] 1 
// S, M[2] 2 . . S 75
unsigned char inbyte() { i M[i]:
.
RS232 loop i=1 to 75
. B=M[i]
return(byte); do OUTBYTE
} .
//
B , OUTBYTE (
void main(void)
{ , OUTBYTE, 
u.bt.NL=inbyte(); // . . B ).
u.bt.NH=inbyte(); // . . , , 
temp_L=u.l; // u.N (ushort) , (
// i 75o M[i] 
// ).
//u.bt.NL u.bt.NH. temp_L , . ., 
// u.l  1 .
.
 , 
, , , , .

78 79
RS232

PDA ). 99 100 ( )
( SPI, C2, MicroWare . .). , , .
.
,  : //*************************************************************************
//* prog90x.c
; //* By : Bauke Siderius
; P89LPC938 //* Discription : ISP/ICP gateway code for LPC90x programmer using MCB900
; //*
//*************************************************************************
; //* Versions
; //*************************************************************************
; //*
PDA: .reg p1.2 ; //* v1.2 August 2003
PCL: .reg p1.3 ; (Clock) //* Added a delay before entering ICP.
; //*
OUTBLPC .macro //* v1.1 August 2003
mov b,#8 //* Put ports in input only when not in use.
METO#: rrc a //* Fixed CRC read out.
mov PDA,c //*
nop //* v1.0 May 2003
nop //* Initial version.
nop //*
clr PCL //*************************************************************************
nop .
nop .
nop .
setb PCL .
nop
nop //*************************************************************************
nop //* shift_out()
djnz b,METO# //* Input(s) : data_byte.
.endm //* Returns : none.
; //* Description : function to shift out data to the part being programmed
//*************************************************************************
() , , void shift_out(char data_byte)
{
p1.2 ( PDA) ,
char shift_bit;
p1.3 ( PCL). , char temp_byte = 0;
c ( rrc ), ,  temp_byte = data_byte; // put databyte in a temp byte
PDA, p1.2 ( mov PDA,c). for(shift_bit = 0; shift_bit < 8; shift_bit++)// shift out 8 bits
, , 3 nop {
PDA, PCL , PCL = 0; // hold clock line low
3 nop. 8 ( 8  if(temp_byte & 0x01) // check if LSB is set
b) . , {
. ( , PDA = 1; // set dataline high
, }
P80LPC938 ICP MSC1210). else
{

PDA = 0; // set dataline low
( , , c }

80 81
RS232 RS232

temp_byte = (data_byte >>= 1); // shift databyte right one, put in temp BYTEIO=OUTB;
PCL = 1; // clock databit for (j=0;j<8;j++){
} PDA=BITIO;
PDA = 1; // set dataline high after transfer PCL=0;
PCL = 1; // hold dataline high after transfer DEL50();
} PCL=1;
//************************************************************************ DEL10();
BYTEIO=_cror_(BYTEIO,1);
MCB900,  }
}
P80LPC9XX. ,
//
, ,
temp_byte, , ,  BITIO () 
PCL. PDA! BYTEIO (: BYTEIO^0). , , PDA,
temp_byte. BITIO c PDA,
:  .
, , 1, PDA 1, PDA=0: (PDA = BITIO), . 
, Bauke Siderius ,
if(temp_byte & 0x01) // check if LSB is set .
{ , ,
PDA = 1; // set dataline high

}
.
else
{
PDA = 0; // set dataline low
} 2.4.
RS232
,  
, !
() C . 2.4.1.
RS232, 
//
// P89LPC938
[4], /
// (TxD RxD) .
sbit PDA = P0^4; (DTRDSR RTSCTS). 
sbit PCL = P0^5; , (TxD RxD),
// XonXoff, , . . 
// BITIO 0 BYTEIO (, Xoff) 
// , ,
bdata unsigned char BYTEIO; .
sbit BITIO=BYTEIO^0; , , , 
// , , 
. (DTR RTS)
.
.
( / (ISP) ). DTR
// ( RESET ), RTS
// / / P89LPC9XX . (
// MSC12XX, ADUC8XX, AT89C51ED2/RD2) RTS 
void OUTBLPC(unsigned char OUTB) { , PSEN. 
unsigned char j; .
82 83
RS232 RS232

, ). 
( 1000 ). (ADM3202, MAX1406, ADM231 .). 
xD , RxD . . , , 
TxD , RxD , , , 
(). , ,  , 
. 
.  , , 
? , . , 
( Xoff, ), , ,
TxD ( . 1 . 0 ),  , .
 ( DTR). , , 
, (. . 
. RxD ( TxD  ). , 
). ( . 1),  (. . TxD ,
, , ( RxD )  .
, . 0). , , 
(. . , ) . , , 
. , ,
, , .  , 
, , , , 
() . ,  . 
, . . .  , .
TxD (. .  , , , .
), .  
? , 115 200 . , 115 200 
RxD ,  : 1/115 200=0,000 008 68 8,7 .
.  RxD 10 (1  + 8 + 1 )
. 1 . 0. , ,  UART  87 . 43 .
(  (515 ), 
), , , , ,  2530 . ,
(. . TxD).  , .
 , 
. , , .
(. . ). , ,
: ,  ,
(. . ). . (. 2.4.1).
, , . 2.4.1.
.

12 , . , . . 
( ADUC8XX,
C8051FXXX), 2 (P89LPC9XX), 4 (MSC12XX) 6
(AT89C51ED2/RD2). , .
 , 

( 

84 85
RS232 RS232

, . 25 ) . . . , 
0 ( RxD 25 
). RxD  . 
, . , , 
RxD . 12 %
, , ,  , /
( Tpp). ( RS232). ,
, . . TxD .
.  , . 
(),  (. 2.4.1), ,
25 . RxD . 
() , . .  1 .
RxD .  ( 
, . . ).
RxD. ,  ,
. , . , RS232
 , , , ( RxD (. . . 0 . 1) . , 
), , , RxD  (
( ) . DSR), , :
RxD . ( ) DSR, RxD,
. . e. , RxD , DSR
,  . RxD , . .
, RxD . , DSR
, (. . , . .
RxD )  ( ) .
. RxD , . . ,
(.. ), , , . . 
. , , ,
. ,  .
,  ,  
RxD ( ). 
. , (. 2.4.2).
,  RxD
. , 
RxD . RxD . 2.4.2.
, ,  !

, , RxD
( ).
( , , 

).
. , . . 
, ,  , RxD DSR 
, ,  RS232 . ,
UART, . . .  (. ,
, , ( . 1.4.1.1, 1.4.4.1.4 1.4.4.2.2).

86 87
RS232 RS232

2 , 
(. 2.4.3). , 
RxD DSR (  . 2.4.2)  . 2.4.4.
, TTL, . .  !

2 .
C8051FXXX


2
. 2.4.3.
!
xD, ,

! . , 
! , 
. , ,

2 ,  
/ (PX.X),
( )
2 , 
TxD 2 ( 1.3.9, . . 1.3.9.1).
, 

( , 5 ).
(. 2.4.2) 2 , 5 , (. 2.4.4).
. . 2,5 .
, 
2.4.2.
, .
,
, 

( !).  (. 2.4.3)  , 
, , 
, .  (. 2.4.1).
,  DOS (Clarion V.3100
. Clarion Software Inc.), 2 : (8051 Macro
. . 2.4.2 2.4.3, RxD Assembler Version 4.02a 2500 A.D. Software Inc, 1985) (C51 Keil Software Inc. V6.14).
, RxD DSR.
, RxD  Clarion v.3100 :
, , RS232,
, . . /. , !
! / ( M1[i] )
RS232. !
RxD, INBYTE routine
TxD , out(3fbh,Y47h) ! TxD ( )
. TxD loop; in(3feh,B); if band(B,2) then break.. !  ( DSR)
( 6 ( 3fbh), . . do DEL20 ! 20
BREAK (. 1). out(3fbh,Y07h) ! TxD ( )
in(3feh,B) ! 3feh
,
loop;in(3fdh,B);if band(B,1) then break.. ! ( "DR"data ready)
TxD ,  in(3f8h,M1[i]) !
/. !
C8051FXXX . Silicon Laboratories. , / ! / ( M[i] )
RS232, . . !
OUTBYTE routine

88 89
RS232 RS232

loop;in(3fdh,B);if band(B,20h);break.. ! (transmitter empty). mov a,sbuf ;Input byte from buffer
loop;in(3feh,B);if band(B,20h);break.. ! .( DSR) clr ri ;Clear flag ri
out(3f8h,M[i]) ! .endm
loop;in(3feh,B);if band(B,2);break.. ! a( DSR)
loop;in(3fdh,B);if band(B,40h);break.. !e (OK to send). ;
in(3feh,B) ! 3feh ;
!
;
OUTBYTE .macro
.
jb RxD,$ ;Waiting enable transfer
mov sbuf,a ;Output byte in buffer
//
jnb RxD,$ ;Waiting disable transfer.WARNING!!!
// /
// jnb ti,$ ;Waiting output last bit (flag ti)
void outbyte(unsigned char byte) { clr ti ;Clear flag ti
while (RXD); // ( ). .endm
SBUF=byte; // . ;
while (!RXD); // ( ).
while (!TI); // . MSC1210Y5. 4 
TI = 0; // (TI). 
}
//
: 1 ( ADUC847, C8051F067/330D) 2
// / ( P89LPC938), 6 (AT89C51ED2) 12
// ( AT89S8252). MSC1210 10 (
unsigned char inbyte() { . . 2.4.1) TxD
unsigned char byte; (. . RxD ) 4 5 , . . 
TXD=0; // . .
while (RXD); // .
DEL10(); // (115200 ).
, MSC1210, 
TXD=1; // . ( . ), ,
while(!RI); // e. 20 ), . 
byte=SBUF; // . , . , 
RI = 0; // (RI). RxD (. . 2.4.1) 
return(byte); 12 ( )  ( 
}
// ), 12 
( ).
. , 
, . ,
2.4.3.

,
RS232,
. .

; 2.4.3.1.
;

;
MSC1210, ADUC834/845, P89LPC938/904, AT89C51ED2/RD2 C8051F067/F330D, 
INBYTE .macro
C51 ( 
clr TxD ;Enable transfer
jb RxD,$ ;Waiting startbit
) , Clarion
call DEL10 ;Call delay 10 mks V3.100 DOS. ,
setb TxD ;Disable transfer Win'98/XP, , ,
jnb ri,$ ;Waiting set flag ri , Win'98/XP DOS,

90 91
RS232 RS232

, Win'98/XP, unsigned char lenl; // . ("u.bt.lenl").


, , ,  }bt;
Win'98/XP . }u;
, //
, . .
unsigned char c,j,a[80];
. unsigned short temp_L; // (temp)
RS232, ,  // .
, . void DEL10(void) {
for (j=0;j<10;j++);
2.4.3.2. MSC1210 }
MSC1210:
void initrs(void) { //
, .  SCON=0xec; //
MSC1210 (. 1.3.5.1 1.3.10). T2CON=0x34; // RS232.
, 
2.4.3.7. T2  RCAP2=3; //V.=115200 .
11 059 200 .  THL2=3;
115 200 .
75 // RCAP2=36; //V.=9600 .
, . // THL2=36;
, }
. .
void outbyte(unsigned char byte) {
while (RXD); // ( ).
SBUF=byte; // .
while (!RXD); // ( ).
 while (!TI); // .
// MSC1210, TI = 0; // (TI).
// 115200 , 11059200 . }
// . inrs115.asm
// unsigned char inbyte() {
#include "stdarg.h" unsigned char byte;
#include "stdio.h" /* printf */ TXD=0; // .
#include "stdlib.h" while (RXD); // .
#include "reg1210.h" /* RS232 */ DEL10(); // (115200 ).
TXD=1; // .
// while(!RI); // e.
// "u.l" "u.bt.lenl" "u.bt.lenh". byte=SBUF; // .
// u.l ( ushort) RI = 0; // (RI).
// u.bt.lenl u.bt.lenh ( byte(unsigned char)) return(byte);
// . }
// lenh() lenl()
// (struct) /**************************************************/
// !!! void main(void)
// {
union{ initrs();
unsigned short l; // ("u.l"). P3DDRL=0x07;
struct{ REN=1; // .
unsigned char lenh; // . ("u.bt.lenh").

92 93
RS232 RS232

; inc dptr
; mov a,r1
.org 0060h cjne a,dph,spin
mov sp,#20h mov a,r0
MAIN: cjne a,dpl,spin
; ;
; .
; ;
; . . clr REN ; .
; spout: pop a
mov SCON,#11101100b ;8 ,2 ,REN=0( ReciveENable=0), OUTBYTE
;TI=0,RI=0,V 1 2, djnz r0,spout
;SM1=SM2=1 3. RB8=TB8=1. ;
; ;
; a T2 . ;
; setb REN ; .
mov T2CON,#00110100b; TF2=0,EXF2=0,RCLK=1,TCLK=1,EXEN2=0, IB: INBYTE
; TR2=1start,CNT2=0,CAP2=0. cjne a,#40h,E
; jmp START
mov RCAP2H,#0ffh ;F.=Freq/(32*(65536(RCAP2H,RCAP2L)))
;65536RCAP2H,RCAP2L=6553665533=3 (253=fch) E: mov 0f2h,#0
jmp $
mov RCAP2L,#3 ;F.=11059200/(32*3)=115200 . ;
DEL10 mov b,#10
;mov RCAP2L,#6 ;F.=22118400/(32*6)=115200 . djnz b,$
;mov RCAP2L,#2 ;F.= 7372800/(32*2)=115200 . ret
;mov RCAP2L,#1 ;F.= 3686400/(32*1)=115200 . ;
;mov RCAP2L,#36 ;65536RCAP2H,RCAP2L=65536(65536,(25636))=36 .end
;F.=11059200/(32*36)=9600 . ;
;mov RCAP2L,#12 ;F.= 3686400/(32*12)=9600 .
2.4.3.3.
ADUC847/834
mov PCON,#80h
mov CKCON,#20h ADUC847/834. 
mov P3DDRL,#07h , .
; (. 1.3.6.1 1.3.10).
; . , 
; 2.4.3.7. T3 
START: setb REN ; . 32 768 .
( 115 200 ) 
mov dptr,#0
ADUC847 ADUC834 . 
INBYTE
mov r0,a ; .
T3CON. 115 200 T3CON 0x82 ADUC847 0x81
INBYTE ADUC834. 115 200
mov r1,a ; . ADUC847.
,
spin: INBYTE; a , :
; ADUC834 7, ADUC847 20.
push a 75
; , .

96 97
RS232 RS232

mov sbuf,a ;Output byte in buffer mov dptr,#0


jnb RxD,$ ;Waiting disable transfer.WARNING!!! INBYTE
jnb ti,$ ;Waiting output last bit (flag ti) mov r0,a ; .
clr ti ;Clear flag ti INBYTE
.endm mov r1,a ; .
;
.DATA spin: INBYTE; a
; ;
; push a
; ;
PLLCON equ 0d7h ; inc dptr
T3FD equ 09dh mov a,r1
T3CON equ 09eh cjne a,dph,spin
; mov a,r0
.CODE cjne a,dpl,spin
.org 0000h ; RST ;
jmp MAIN ; .
.org 0003h ; INT0 ;
reti clr REN ; .
.org 001bh ; TF1 spout: pop a
reti OUTBYTE
.org 0053h ; TIC djnz r0,spout
reti ;
; ;
; ;
; setb REN ; .
.org 0060h IB: INBYTE
mov sp,#20h cjne a,#40h,E
jmp START

E: jmp $
MAIN: mov PLLCON,#0h ;
; DEL7 mov b,#20 ;7ADUC834,20ADUC847
djnz b,$
; ret
; . . ;
; .end
;
;
; a T3 . 2.4.3.4.
; AT89C51ED2(RD2)
mov T3CON,#82h ;#82h ADUC847, #81h ADUC834|115200
mov T3FD,#2dh AT89C51ED2:
; , . 
mov SCON,#40h;52h (. 1.3.7.1 1.3.10). 
; , 2.4.3.7.
; .
;
(Baud Rate Generator BRG) 11 059 200 .
START: setb REN ; .
115 200 .

100 101
RS232 RS232

75 return(byte);
, . }
, /**************************************************/
. . void main(void)
{
initrs();


REN=1; // .
//
// AT89C51ED2,
START:
// 115200 , 11059200 .
// . inrs_ed2.asm
lenl=inbyte();
//
lenh=inbyte();
#include "stdarg.h"
#include "stdio.h" /* printf */
l=lenh*256+lenl;
#include "stdlib.h"
#include "at89c51xd2.h"
for(i=0;i<l;i++){
unsigned char c,j,lenl,lenh,a[80];
a[i]=inbyte();
int i,l;
}
REN=0; //.
void DEL7(void) {
for (j=0;j<7;j++) {}
for(i=0;i<l;i++){
}
outbyte(a[i]);
}
void initrs(void) {
REN=1; //.
CKCON0=1;
c=inbyte();
PCON=0x80;
if (c==0x40) goto START;
SCON=0xec;
E:
BRL=250; //115200
goto E;
BDRCON=0x1f;
}
}

void outbyte(unsigned char byte) {




while (RXD); // ( ).
;
SBUF=byte; // .
; MK AT89C51ED2 RS232 (
while (!RXD); // ( ).
; ); .
while (!TI); // .
; F.=11059200 , X2. 115200 9600 .
TI = 0; // (TI).
; TxD RxD.
} ; OUTBYTEC.EXE(CLA) OUTBYTE1.EXE(BAS).
;
unsigned char inbyte() { ;
unsigned char byte; ;
TXD=0; // . ; !!!!!!!
while (RXD); // . ;
DEL7(); // (115200 ). ;
TXD=1; // . ;
while(!RI); // e. INBYTE .macro
byte=SBUF; // . clr TxD ;Enable transfer
RI = 0; // (RI). jb RxD,$ ;Waiting startbit

102 103
RS232 RS232

reti OUTBYTE
.org 001bh ; TF1 djnz r0,spout
reti ;
.org 0053h ; TIC ;
reti ;
; setb REN ; .
; IB: INBYTE
; cjne a,#40h,E
.org 0060h jmp START
; mov sp,#20h
MAIN: E: jmp $
; .end
; org $ ;
mov sp,#20h
2.4.3.6
; C8051F067/330D
; . .
, 
;
C8051FXXX , :
SPINIT: mov SSTAT,#00h ; 51 RS232.
mov P1M1,#02h ; : 1. (SYSCLK) 
mov P1M2,#01h ;TxDpush/pull_output, RxDinput. ( ), .
mov SCON,#40h ; SCON, SM1, 0, SM1=1. 2.
mov BRG0,#30h ;30h=48.Vobm=CCLK/[(BRG1*256+BRG0)+16]= .
mov BRG1,#00h ;7372800/[(0*256+48)+16]=7372800/64=115200. 3. (
mov BRGCON,#03h ; SBRGS BRGEN.
). 
;
, .
; .
; 4. ,
START: setb REN ; . /, . ,
P0.0 TxD ( C8051067),
mov dptr,#0 ( P0.0)
INBYTE : TxD=0 TxD=1.
mov r0,a ; .
INBYTE
C8051F067
mov r1,a ; . C8051F330D.
(. 1.3.9.1 1.3.10). 
spin: INBYTE; a ,
; 2.4.3.7.
push a C8051F067 
; 11 059 200 ,
inc dptr C8051F330D 24,5 .
mov a,r1 115 200 .
cjne a,dph,spin , 75 
mov a,r0
, .
cjne a,dpl,spin
;
; . C8051F067
; 
clr REN ; . //
spout: pop a // C8051F067,

112 113
RS232 RS232

OSCICN = 0x83; // //
RSTSRC = 0x06; //. //u.bt.lenl u.bt.lenh.
//
XBR0 = 0x01; // UART . for(u.l=0;u.l<temp_L;u.l++){ //
XBR1 = 0x40; // . a[u.l]=inbyte(); //
P0MDOUT |=0x10; // TxD0 , RxD0. } // .
P1MDOUT |=0x80; // Tx0 . // u.l (, u.l++)
// //
SCON0=0x10; // RS232 (UART0). //
TH1=(SYSCLK/BAUDRATE/2); // //u.bt.lenl u.bt.lenh.
CKCON |= 0x08; // T1. // u.l ,
TL1=TH1; // u.bt.lenl u.bt.lenh 
TMOD &= ~0xf0; //
TMOD |= 0x20; // .
TR1=1;
// TI0=1; REN0=0; // RS232 .
}
for(u.l=0;u.l<temp_L;u.l++){ //
void outbyte(unsigned char byte) { outbyte(a[u.l]); //
while (RX0); // ( ). } // .
SBUF0=byte; // .
while (!RX0); // ( ). REN0=1; // RS232 .
while (!TI0); // .
TI0 = 0; // (TI0). c=inbyte(); // ="@",
} if (c==0x40) goto START; // ,
E: // .
unsigned char inbyte() { goto E;
unsigned char byte; }
TX0=NUL; // . //
while (RX0); // .
DEL20(); // (115200 ).
TX0=ONE; // .
while(!RI0); // e. 2.4.3.7. DOS
byte=SBUF0; // .
RI0 = 0; // (RI0). , 
return(byte); 2.4.3.2 ( MSC1210), 2.4.3.3 ( ADUC847/834), 2.4.3.4 ( AT89C51ED2/RD2),
} 2.4.3.5 ( P89LPC938/904) 2.4.3.6 ( C8051F067/330D)
/**************************************************/ Clarion V3.100 Hello.cla, DOS.
void main(void) RS232 ( COM 1:N,8,1,115 200),
{ , 75 (
initrs();
),
REN0=1; // .
( ) . (INCLUDE)
START: (Graphic User Interface).
u.bt.lenl=inbyte(); // . . ( 
u.bt.lenh=inbyte(); // . . Windows).
temp_L=u.l; // 2.3.1 
// temp_L. , . Hello.cla,
// u.l (ushort) .
//

118 119
RS232 RS232 WINDOWS98/XP

!in(3feh,B) ! 3feh ( Enter)


loop;in(3feh,B);if band(B,2);break.. ! a( DSR) ; k .
loop;in(3fdh,B);if band(B,40h);break.. !e (trasmitter holding k = 146.
register empty.OK to send). .
in(3feh,B) ! 3feh
!

DEL100MS routine
2.5. RS232
T#=CLOCK();loop while CLOCK()T#<10. ! 0,1 . Windows98/XP
DEL200MS routine
T#=CLOCK();loop while CLOCK()T#<20. ! 0,2 . 2.5.1.
DEL50 routine
loop 15000 times RS232 Windows  
. . , 
DEL1400 routine ( Clarion v3.100 DOS Clarion v.6.0 Windows),
loop j=1 to 1400 . ( ) 
. . DOS SCREEN (),
DEL20 routine Windows Window (). . 
loop 40000 times
Window SCREEN ,
.
, , , 
!
. , , 
, Window , 
 Hello.pr
 . 
#system auto exe , Window
#model extended . , (!), 
. 
#pragma data(stack_size=>24576,threshold=>4096) ( , ), 
#pragma check(stack=>on,index=>on) .
#pragma link_option(map=>off,case=>on) ( ) . ,
#compile hello.cla /check(stack=>off,nil_ptr=>off,index=>off) Window
/debug(vid=>off,line_num=>off) ( ).
#pragma link(%clapfx%dos.lib)
.
#pragma link(%clapfx%xgui.obj)
DOS Windows .
#set exports='hello'
#link hello , , Clarion 6.0 ( , ,
Clarion5.5 ), . Clarion6.0 
(. 2.4.3.7). threadmodel, 
( Win'XP). thread 
. 2.4.3.7.
.
, Clarion 6.0 . 
.
()
, , .
,
( Windows):

124 125
RS232 RS232 WINDOWS98/XP

START OK p 1
 (p=1), break, (thread'a)
 accept end. Cancel p 0
(p=0) break ,
accept (thread'a) accept end. accept end 
! p,
case accepted() START ( p=1) ( p=0), .
of ?Ok
. p,
p=1
: START
break
of ?Cancel (goto START), Cancel E (goto E), 
p=0 .
break . , Clarion 5.5 (
end ! ot case Clarion v.3.100 DOS) 
! .
end ! accept Clarion6.0 , 
, ,
if p=0 then goto E. CTRLALTDEL, .
, , ,
goto START
RESET . ? acceptend
(thread), Clarion6.0, ()
E return
. 
( !).
acceptend, 
( OK CANCEL) 
OK
acceptend, , acceptend 
Cancel(). . OK
, p 
, START. Cancel
. ,
E, . . . 
acceptend .
, , . ,
, 
DOS (. 2.4.3.7):
.
START . ( ), 
 DOS Windows .

2.5.2. RS232 Win'98/XP
accept
, RS232
!
Windows . API (Application
case accepted()
of ?Ok Program Interface) . 
goto START / ( RS232 COM).
of ?Cancel API , 
goto E Windows. API
end ! ot case . , API , , 
!  (, )
end ! accept RS232, API .
E return , , . .
, , , API, 
? , .

126 127
RS232 RS232 WINDOWS98/XP

/ (
). GetCommState . handle , 
/ , DOS. , (PortStruct) .
/ , . . o API:
. ,  TransmitCommChar ( COM),
RS232. WriteFile ( ), () , 
, RS232 . .
API, / COM. ReadFile.
, () ,
2.5.3. RS232 API ( ) COM. 
, , ,
API, 
. , , , 1. 
RS232 32 . API
SetupComm ( COM), , 
MSDN ( ).
, , ( 1),
API Clarion 6.0 Hello.clw, 
, , .
Windows98/XP ( ).
, . ,
, API. , Clarion 5.5
6.0 (WINAPI.EXE),  WindowsXP ( Windows).
API. , PurgeComm ( COM)
, , , . , 
.
ReadFile. 1,
API, RS232,
10 10 ReadFile,
CreateFileA ( ). hndle
10, 1 .
, .
: ?
handle ( ). CreateFileA 
10 , 10 . .
.
, CreateFileA, COM,

5 ( 7), CreationDisposition
COM: BuildCommDCBA, (
( ) Open_Existing (. . 
, ,  . .). 
). , COM , 
: ControlString PortStruct.
, (DCB), ,
ControlString , , ,
, DTR RTS, , 
: ControlString='Com1:115 200,N,8,1', ,
. (. .
COM1 ( 115 200 ), , 
CreateFileA), BuildCommDCBA
8  1.
SetCommState, , , DTR RTS
PortStruct , 
(. . ),
COM , ,
, BuildCommDCBA SetCommState .
ControlString (, , ). ,
BuildCommDCBA SetCommState , DTR RTS
, , ControlString 115 200, PortStruct . , DTR
9600, 9600 . ControlString RTS . 
9600, PortStruct 115 200,  RTS DTR,
. PortStruct , RxD . , , ,
ControlString, . COM (13), ( )
, BuildCommDCBA (. . ).
; , ,  ReadFile,
. , . , ,
, BuildCommDCBA, COM  3 , ReadFile 2 , 
SetCommState ( ).  . 2 , , 
. ( !).
128 129
RS232 RS232 WINDOWS98/XP

, , ( 
( )  ;
(RxD) 2) SetCommBreak ( Break) TxD
. , . ( )
3) ClearCommBreak ( Break) TxD .
, RS232 API. , EscapeCommFunction .
e, DTR (. .  DSR, CTS, DCD RI
RST), DTR GetCommModemStatus ( ).  Windows98
( ) WindowsXP. , , DSR RxD  
RxD (, ). , Windows 98 . Windows XP
() . , .
, (
, () , ) API SetCommMask
. ( COM) WaitCommEvent ( COM
. RS232,  ). , 
RxD .
, , ,  SetCommMask , 
,  ,
. , ,  . , (
75 , 2 (. . 77), ), .
75 , , 77 , , ,  WaitCommEvent 2 . 1
ReadFile 77 ( 1 ) 1 ( 77 ). SetCommMask . 
(78) . , , , 
, , . 2 .
COMSTAT ( COM), 2 , ,
CbInQue ( ). COMSTAT, , API SetCommMask 2 , 2
ClearCommError ( COM). , ,  WaitCommEvent,
, .
: API ClearCommError, . 2 : COM (EV_RXCHAR)
CbInQue, 1 API ReadFile DSR (EV_DSR).
CbInQue . API PurgeComm 
, .
, COM  1. 2 : EV_RXCHAR+EV_DSR:
/ DOS Windows98/XP 
. , DTR RTS !
( API). , loop
1 , . . if SetCommMask(CommPort,EV_RXCHAR+EV_DSR) |
, . , in,  then break. ! DSR
COM, 100 ; .
!
, . API 
, ,
2. DSR , , ,
. .
ClearCommBreak:
(DTR, RTS TxD) COM
API, : !
1) EscapeCommFunction COM ( loop
Escape (Esc), ),  loop until WaitCommEvent(CommPort,EvtStatus,0).

130 131
RS232 RS232 WINDOWS98/XP

if band(EvtStatus,EV_DSR) !DSR Sleep(100)


if ClearCommBreak(CommPort) then break. 100 , .
. API COM .
. , , , MSDN. 
!
API MSDN ,
, , 
3. COM:
.
!
loop
2.5.3.1. ,
loop until WaitCommEvent(CommPort,EvtStatus,0). API, Win'98/XP
if band(EvtStatus,EV_RXCHAR) then break. API, 
. , RS232 
!
. .
HELLO.CLW, . 
, , , DOS (Clarion v.3.100),
WaitCommEvent : 2.4.3.7, Windows Clarion 6.0.
,
1. COM: DOS (. 2.4.3.7).
HELLO.CLW
!
RS232 (9600 115 200 ). ,
loop
if SetCommMask(CommPort,EV_RXCHAR)| , RS232
then break. ! .
. HELLO.CLW  Hello.prj.
!
HELLO.CLW
2. O ( , ): 
!
! ! 75 RS232
loop until WaitCommEvent(CommPort,EvtStatus,0). ! API Windows98/XP.
! ! : INRS115.c
!

, WaitCommEvent PROGRAM
, . . , . 
API, !========================
, (. 2) ,  INCLUDE('Equates.CLW')
, o INCLUDE('TplEqu.CLW')
(EV_RXCHAR), ( INCLUDE('Keycodes.CLW')
!). INCLUDE('Errors.CLW')
!========================
COM .
CloseHandle ( Handle),  !
. !
API, ,  !
Sleep (). , , COM C byte
, , Clarion 6.0, . A byte
: B byte

132 133
RS232 RS232 WINDOWS98/XP

#pragma optimize(cpu=>386) Win'XP (. 2.5.3.3),


#pragma optimize(speed=>on) , COM
#pragma define(NULL=>off) (. 2.5.3.4).
#compile "hello.clw"
#pragma link("hello.lib") . 2.5.3.3.

#pragma link("WindowsShell.Manifest") (Win'XP)
#link "hello.exe"

Win'98(SE2) Win'XP(SP2).
Win'98 (. 2.5.3.1).
COM, ( 
, ). 
. ( ) .
. 2.5.3.4.
1 COM 115 200 ( . 2.5.3.1)
(. 2.5.3.2). (Win'XP)
.
k, (k = 179, . . 
:) ). 
, . 2.5.3.2 2.4.3.7, ( 
) . , ,
(DOS Win'98).
. 2.5.3.1.

(Win'98)

. 2.5.3.2.

(Win'98)

2.5.4. RS232
/ COM-

2.5.4.1.
RS232 Windows
/ COM , , , 
.

. , DOS (Clarion v.3.100), ,
2.4.3.7, / in ( , 
) out ( , ). 
RS232 (COM). Windows (Clarion 6.0) 
/ .

142 143
RS232 RS232 WINDOWS98/XP

/ (in( ) INP(USHORT),BYTE,PASCAL,NAME('Inp32')
out( ) ) . Win'98 ,  OUTP(USHORT,BYTE),PASCAL,NAME('Out32')
/ . Win'XP / (in( ) out( ) ) END
( ). !
Win'XP , 
/ , 2 .
( COM), . inpout32.dll /
, COM ( . .  .
INP( ) OUTP( ),
/ / ). Win'98 ,
,
/ .
Win'XP ( ,
, , ( 
/ Win'XP).
). INP( ) OUT( ) , : ) 
(inpout32.dll), 
2.5.4.2. / , )
Clarion 6.0 Win 98/XP (, , , API). ,
/ Clarion 6.0 , RS232.
2 . () / 
( ) , .
(inpout32.dll), Clarion 6.0 (in out),
2 2 : INP( (C++), Clarion 6.0. 
) OUTP ( , ) Win'XP (,
Clarion6.0 , .
Win'98 ).
2 In.cpp Out.cpp, C++, 
/ , / Win'XP.
.
USHORT, BYTE.
, //
OUTP(USHORT,BYTE). , (3f8h) COM 1  // In.cpp
'A', ASCII 41h. : //
#pragma save
OUTP(3f8h,41h) #pragma call(inline => on, reg_param => (dx), reg_return => (ax))
static unsigned char inportb(unsigned int Port_number)=
, INP(USHORT). , {
COM1 (3feh). : 0xEC, // in al,dx
};
B=INP(3feh) #pragma restore

B BYTE. extern "C" unsigned char INP(unsigned int Port_number)


, {
: 1) inpout32.dll inpout32.lib unsigned char byte;
libmaker.exe, Clarion6.0 ( , ,  byte=inportb(Port_number);
Clarion 6.0), inpout32.lib return byte;
; 2) }
INP(USHORT) OUTP(USHORT,BYTE). , //
:
//
! // Out.cpp
MODULE('INPOUT32') //

144 145
RS232 RS232 WINDOWS98/XP

#pragma save 3f8h Port_number, 


#pragma call(inline => on, reg_param => (dx,ax)) byte=inportb(Port_number); ,
static void outportb(unsigned int port, unsigned char byt)= byte, 
{ return byte.
0xEE, // out dx,al In.cpp , , 
}; , 
#pragma restore , () Windows (Clarion6.0) .
Out.cpp. ,
extern "C" void OUTP(unsigned int Port_Number, unsigned char byte) In.cpp ( ) , 
{ , Out.cpp ( dx
outportb(Port_Number,byte); , ax).
} in.cpp ,
// Out.cpp.
.
2 . , : ) 
In.cpp. , 2) .
Clarion6.0 C++ inline  
, ( C++)  :
. inline , ,
, static. static MODULE('IN.CPP')
, , (  INP(USHORT),BYTE,NAME('_INP')
C++ ). , ,  END
, ; MODULE('OUT.CPP')
( ) extern, . .  OUTP(USHORT,BYTE),NAME('_OUTP')
. in.cpp 2 . END
, static, 
inline a (in al,dx), 0xEC.  . ( _ ) INP
( in), ,  OUTP , . 
dx , (al). In.cpp Out.cpp, ,
, , (  extern C. C .
#pragma save), , inline, .
(RS232) dx ax ( In.cpp Out.cpp ,
#pragma call(inline  on, reg_param  (dx), reg_return  (ax))). External source files ( ), Add () 
,  , , In.cpp. , , 
0xEC, , dx, Hello.clw, / 
al.  ,  (Hello.prj), .
#pragma restore, /
. Win'XP, , .
, 
extern. 
( ) ,
2.5.4.3. /
. Win'XP
.  , ,
B=INP ( ), B  / , inpout32.dll.
BYTE, USHORT ( 3f8h), . . : / (INP( ) OUTP( ) ),
In.cpp Out.cpp .
B=INP(3f8h), inpout32.dll ,
In.cpp Out.cpp.

146 147
RS232 RS232 WINDOWS98/XP

, , 
/ Win'XP. 
, , 2 :
UserPort, (Tomas Franzon), 
, Portmon, (Mark Russinovich) (www.sys
internal.com). .
UserPort. 
/
Win'XP.
Win'XP . UserPort
UserPort.pdf. UserPort UserPort.sys,
. /
UserPort.sys C:\WINDOWS\SYSTEM32\DRIVERS\
. 
In.cpp Out.cpp. , , , 
UserPort.sys In.cpp Out.cpp COM ) , / . 2.5.4.3.2.
, .  (. 2.5.4.3.2). () , 
Capture
, COM. COM . COM 1 (, , COM 2). ()
. ,  Capture, Ports ()
/ Win'XP. COM 1: Serial0 COM 2:Serial1 (. . 2.5.4.3.3).
, , Portmon ( Portmon.
). , / COM 1 COM 2 Clarion6.0 (. .
/ . , , In.cpp Out.cpp), /
( Capture )  COM 1 COM 2 ( , DOS, 
. In.cpp Out.cpp /  , tb.exe, Clarion v3.100 ..). , ,
Clarion6.0 Portmon : 1)  Hello.exe, DOS Clrion v.3.100 (Hello.cla)
/ , 2) ( COM) . 2.4.3.7. , DOS 
, . , AUTOEXEC.NT  DOS , :
. 2.5.4.3.1.
(. 2.5.4.3.1). 
Portmon Capture (), (COM tdrvses.exe,

CONFIG.NT :

dos=high, umb
device=%SystemRoot%\system32\himem.sys
files=40

, AUTOEXEC.NT CONFIN.NT C:\WIN


DOWS\SYSTEM32\. DOS ,
CONFIG.NT AUTOEXEC.NT .
Win'XP, / COM 2 
UserPort Portmon . 
Portmon. 
, Win'XP
, . 2.5.4.3.12.5.4.3.3.

148 149
RS232 RS232 WINDOWS98/XP

MODULE('Comm Prototipes')
!
CreateFileA(*CSTRING,ULONG,ULONG,LONG,ULONG,ULONG,UNSIGNED),|
SIGNED,RAW,PASCAL,NAME('CreateFileA')
CloseHandle(SIGNED),BOOL,PROC,PASCAL
!
END

API :

!
! APICOM 1 .
!
CommPort UNSIGNED !(handle).
PortCString CSTRING(10) !'COM1/COM2'
OPEN_EXISTING ULONG(3)
. 2.5.4.3.3. !
, 

COM 1 COM 2
, .
COM :
, ,
/. ,  PortCString='COM1'
/ CommPort=CreateFileA(PortCString,0,0,0,OPEN_EXISTING,0,0)
.
, UserPort ( UserPort.sys, , PortCString 'COM1',
C:\WINDOWS\SYSTEM32\DRIVERS\)  a API CreateFileA() . , 
/ Win'XP.  COM ( , , ) 
Portmon.exe . , . /
Portmon , . COM.
2.5.4.3.12.5.4.3.3 . ,  COM API CloseHandle():
/ ,
UserPort.sys, loop until(CloseHandle(CommPort)). ! CommPort'a.
.
, UserPort.sys  , COM, 
/, . COM clacom32.dll,
. ? . COM Windows,
Gap Development Company (www.gapdev.com) ClaCom ( 
2.5.4.4. COM- ).
/ Win'XP clacom32.dll COM, 
COM. : ) clacom32.dll clacom32.lib
, COM, API Crarion 6.0 libmaker.exe 
(, , ). API, Clarion 6.0; ) COM
COM, 2.5.3 (  :
Hello.clw). API 2:
COM . (CreateFileA())  MODULE('CLACOM')
, (CloseHandle()) . SetPort(SHORT),PASCAL,NAME('_SetPort@8')
. ResetPort(SHORT),PASCAL,NAME('_ResetPort@8')
END

150 151
RS232 RS232 WINDOWS98/XP

COM: Hello.clw

ComNum short !
! 75 RS232
COM : !

ComNum=0 ! 0COM1,1COM2 PROGRAM


SetPort(ComNum)
ResetPort(ComNum) INCLUDE('Equates.CLW')
INCLUDE('TplEqu.CLW')
INCLUDE('Keycodes.CLW')
, COM 1, ComNum 
INCLUDE('Errors.CLW')
, COM2 . 
!
SetPort(ComNum),  !
ResetPort(ComNum). !
Clarion6.0 . C byte
A byte
2.5.4.5. , B byte
/ COM- Win'98/XP S string(80)
BT byte
, . 2.5.4.22.5.4.4. M byte,dim(80),over(S)
Clarion 6.0 / Win'98/XP S1 string(80)
3 . M1 byte,dim(80),over(S1)
1. : i ushort
j ushort
) / Clarion6.0
k ushort
C++ (In.cpp Out.cpp),  (*.prj);
CH byte
) /, a N1 long
inpout32.dll, inpout32.lib lib STR string(5)
maker.exe  (*.prj). ,  p byte
INP( ) OUTP( ). !
2. / , ! QueryPerformanceCounter
UserPort.sys C:\WINDOWS\SYSTEM32\DRIVERS\.  !
inpout32.dll UserPort.sys  CSTARTL ulong
. CSTARTH long
3. COM : ) API ) cla CSTOPL ulong
com32.dll. CSTOPH long
DC long
Hello.clw, 
DELTAC long
. (  !
). , Hello.clw,
. In.cpp
Out.cpp UserPort.sys; COM !
clacom32.dll. , , , ! APICOM 1 .
Win'XP,  !
WindowsShell.Manifest. CommPort UNSIGNED !(handle).
COM: COM 1: N,8,1, 115 200.  PortCString CSTRING(10) !'COM1/COM2'
, . OPEN_EXISTING ULONG(3)
!

152 153
RS232 RS232 (ISP)

#pragma define(NULL=>on)
#compile "Hello.clw"
#compile "In.cpp"
#compile "Out.cpp"
#pragma link("hello.lib")
#pragma link("inpout32.lib")
#pragma link("clacom32.lib")
#pragma link("WindowsShell.Manifest")
#link "hello.exe"

COM, ,
Hello.cla,
DOS (Clarion v.3100) . 2.4.3.7,
. , 
API . 2.5.3, 
API. ,
, , , 
API, ,
, / .  . 2.5.4.5.2.
API, 
RS232. 2.6. RS232 Hello.exe Win'XP
COM  
, .  (In_System_Programming)
Hello.exe COM1,
. 2.6.1.
Hello.exe Win'98
(. 2.5.4.5.1). , 
( , , k 176), RS232,
. 2.5.4.5.1. Windows. , . ISP
MSC12XX, ADUC8XX P89LPC9XX, . Texas Instru
Hello.exe Win XP (. 2.5.4.5.2), k = 239.
Win'98
ments, Analog Devices Philips 
.
, , Texas Instruments
MSC12XX , 19 200 ;
Analog Devices
( ADUC8XX),
; 
P89LPC9XX , 
. 
MSC12XX, ADUC8XX P89LPC9XX ISP 
, . 1.3.5.1 (MSC12XX),
. 1.3.6.1 (ADUC8XX), . 1.3.8.1 1.3.8.3 (P89LPC9XX) . 1.3.10 ( 
).

AT89C51ED2(RD2),
(. 1.3.7.1), . ATMEL ( FLIP v.2.4.4), 
, () ,

160 161
RS232 RS232 (ISP)

. FLIP v.2.4.4  PROGRAM


115 200 .  !
 !
,  !
M byte,dim(100) ! OUTBYTE.
. , 
S string(100),over(M) ! OUTBYTE.
. 1.3.7.1, , M1 byte,dim(100) ! INBYTE.
. S1 string(100),over(M1) ! .
C8051F067 C8051F330D !
. Silicon Laboratories ISP: JTAG C2 ( USB ! USEC.
DEBUG), . 1.3.9.1,  ! 11.059 => 10=0Ah => 30h,41h.
,  ! 22.118 => 20=14h => 31h,34h.
IDE v.2.5.2. SUSEC string('<52h,57h,46h,42h,30h,41h>')
. !MUSEC byte,dim(6),over(SUSEC)
!
ISP: ! MSECL.
! 11058 => 32h => 33h,32h.
RS232 (MSC1210XX, ADUC8XX P89LP93X),
! 22117 => 65h => 36h,35h.
C2 (P89LP9XX); SMSECL string('<52h,57h,46h,43h,33h,32h>')
!MMSECL byte,dim(6),over(SMSECL)
ISP: !
FLIP v.4.4 . AMTEL (FN89C51TD2(RD2) RS 232, ! MSECH.
IDE v.2.5.2 . Silicon Laboratories (C8051F067 JTAG ! 11058 => 2Bh => 32h,42h.
C8051F330D) C2 USBDEBURG. ! 22117 => 56h => 35h,36h.
SMSECH string('<52h,57h,46h,44h,32h,42h>')
!MMSECH byte,dim(6),over(SMSECH)
2.6.2. MSC12XX ISP !
! M0000.
RS232 SM0000 string('<4dh,30h,30h,30h,30h>')
MSC12XX ISP !MM0000 byte,dim(5),over(SM0000)
RS232 !
(. 1.3.5.1). ! M8000.
MSC121X ISP RS232. SM8000 string('<4dh,38h,30h,30h,30h>')
!MM8000 byte,dim(5),over(SM8000)
downti.cla DOS (Clarion v.3.100) 
!
DOS, DOS Win'98 Win'XP.  L ulong ! .
(downti.pr) . N ushort
Windows (Clarion6.0). NSTROK ushort(0) ! *.hex
Win'98 Win'XP. Ispmsc.clw,  Ispmsc.prj NOST ushort !
COM 1 115 200 . NSYMB ushort ! .
: file.hex. file.hex  NP ushort(0) ! .
92 , (*.bin) 32 NP1 ushort
( MSC1210Y5). k ushort
k1 ushort
KL ushort
downti.cla
B byte
i ushort

j ushort
!
i1 ulong
! file.hex msc1210.
T1 long
!

162 163
RS232 RS232 (ISP)

down834c.cla

!
! file.tsk ADUC8XX.
!_
PROGRAM
!
!
!
CER string('<07h,0eh,01h,41h,beh>') ! ERASE.
MER byte,dim(5),over(CER) ! ERASE.
C115 string('<07h,0eh,03h,42h,81h,2dh,0dh>') ! 115 .
M115 byte,dim(7),over(C115) ! 115 .
M1 byte,dim(25) ! .
. 2.6.2.2. S1 string(14),over(M1) ! ADUC.
SN string(3)
!
LEND byte ! .
!
MSC1210 ! NB byte ! .
Ispmsc.clw L ushort ! .
LOST byte ! L%16 .
D byte,dim(16) ! .
S0 string(16),over(D) ! .
file.hex, 32 , SD ushort ! .
( 11 ), Win'XP ADR ushort !x .
DOS. ,  ADRMAX ushort ! .
Win'XP / . M byte,dim(25) ! OUTBYTE.
32 11 , 2,9 /  MKS byte,dim(21) ! .
MSC1210 ISP. SUM ushort ! .
KSUM byte ! .
2.6.3. ADUC8XX ISP N ushort
RS232 k ushort
B byte
ADUC8XX ISP RS232 i ushort
 Y00h byte(00h)
(. 1.3.6.1). Y01h byte(01h)
Y02h byte(02h)
ADUC8XX ISP RS232. aduc834c.cla Y03h byte(03h)
Y04h byte(04h)
DOS (Clarion v.3.100) DOS,
Y06h byte(06h)
DOS Win'98 Win'XP.  aduc834c.pr.
Y07h byte(07h)
ispaduc.clw Windows (Clarion6.0). Y12 byte(12)
Win'98 Win'XP.  ispaduc.prj. Y47h byte(07h)
COM 1 115 200 .  Y80h byte(80h)
: file.tsk. ISP  Y0fh byte(0fh)
ADUC8XX ( , 
) , file.tsk  BINARY FILE,PRE(BIN),DRIVER('DOS'),NAME('file.tsk')
63 488 (62 ) RECORD RECORD
ADUC847BS625. STR string(65500) !
..
!

184 185
RS232 RS232 (ISP)

. 2.6.3.1.
. 2.6.3.2.


ADUC847

2.6.4. P89LPC9XX
ISP RS232 ICP C2

) 2.6.4.1.
P89LPC9XX . 
file.tsk,
, RS232, defacto InSystem
63 488 (62 ), Programming (ISP), . . . ,
( 22 ), Win'XP  C2, , 
DOS, 1 . ADUC847 . , 
, 63 488 22 . 2,83 /. P89LPC9XX InCircuitProgramming (ICP), . . 
. C2
. 2.6.3.2. . Silicon Laboratories ( C8051F330D).

ICP P89LPC9XX
ADUC847 ( P89LPC932), ISP
Ispaduc.clw . , ISP, ICP.
() ()
P89LPC92X P89LPC93X 
P89LPC9XX. 
P89LPC90X ( 8 ). 
ICP.
( 2005 .) : 
P89LPC938 P89LPC93X P89LPC904
P89LPC90X. 2
(P89LPC938 P89LPC904) ,
ISP ICP.
P89LPC938 : ISP ICP, a
)
P89LPC904 ICP.

202 203
RS232 RS232 (ISP)

4) ICPlpcTI.clw , Windows (Clarion


v.6.0) Win'98/XP,  ICPlpcTI.prj.
. 2.6.4.3.2.
4 , 
isp938.clw (Win'XP) 2.4.
, , 
.

B938_9XX.C

//
// P89LPC938 P89LPC938/904(ICP).
// 115200 , 7372800 .
//
#include "stdarg.h"
#include "stdio.h"
#include "stdlib.h"
#include "intrins.h"
//#include "reg1210.h"
#include "reg935.h"
(file.hex), //
//
//
2,6 . , *.bin
( hex2bin), 5917 (. . 6 ).
//
5917 2,64 , 2,24 /  // MSC1210
P89LPC938 ISP.  //
MSC1210 (2,9 / . 2.6.2.2) // sbit VDD = P1^0;
ADUC847 (2,83 / . 2.6.3.2), , // sbit RST = P1^1;
P89LPC938  // sbit PDA = P1^2;
MSC1210 ADUC847. // sbit PCL = P1^3;
//

2.6.4.4. P89LPC9XX //


ICP // P89LPC938
//
sbit VDD = P0^3;
P89LPC938 P89LPC904  sbit RSTLPC = P0^2;// RST LPC904 .
, . 1.3.8.11.3.8.3, 1.3.5.1.  sbit PDA = P0^4;
, P89LPC938 sbit PCL = P0^5;
P89LPC904 ICP : //
1) B938_9XX.C, , P89LPC938, 
bdata unsigned char BYTEIO;
;
sbit BITIO=BYTEIO^0;
2) BMSC_9XX.C, , MSC1210, 
; //
3) PROGLPC.CLA , DOS (Clarion // "u.adr" "u.bt.adrl" "u.bt.adrh".
v.3.100) DOS Win'98/XP DOS,  // u.adr ( ushort)
proglpc.pr; // u.bt.adrl u.bt.adrh ( byte(unsigned char))

236 237
RS232 RS232 (ISP)

2.6.5. AT89C51ED2(RD2)
ISP RS232
AT89C51ED2
(. 1.3.7.1) 
FLIP v.2.4.4 . ATMEL.
(. 1.3.7.1).
(. 1.7.7.1)
. 2.6.4.4.2.

COM1 . FLIP v.2.4.4 
ICPlpcTI.clw(Win'XP), (. 2.6.5.1,). Setting ()
Preferences (). (. 2.6.5.1,) 

P89LPC938
AutoISP (ISP) More ();
B938_9XX.C Advanced RESET ( RESET) (. 2.6.5.1,)
RST(DTR) PSEN(RTS) low ( ) OK.
ICP
P89LPC938 (a) P89LPC904 ()
FLIP (. 1.3.7.1).
) RS232 (. 2.6.5.1,); 
(. 2.6.5.1,) COM 1, 115 200
Connect (). , (. 2.6.5.1,),
, .
*.hex (. 2.6.5.1,, ,
inrsed2c.hex).

. 2.6.5.1.
!

FLIP


AT89C51ED2 (.
. 282286)

(. 2.6.4.4.1) ,
PROGLPC.CLA (DOS) ICPlpcTI.clw (Win'XP), 
P89LPC938 P89LPC938 ICP,
( (6,42 6,41 )
file.tsk 6 )
P89LPC938 MSC1210 ( 
6,41 8,22 ) . , , 
.
. 2.6.4.4.2 , 
(1 ) P89LPC938 (1,09 ), 
P89LPC904 (1,71 ). , , 
(16 P89LPC904 64 )
P89LPC938), 64 
, 4 16 (. ICP 9XX).

280 281
RS232 RS232 (ISP)

. 2.6.5.1.
!
. 2.6.5.1.
! FLIP

FLIP
AT89C51ED2
()
AT89C51ED2
()

) )

) )

282 283
RS232 RS232 (ISP)

. 2.6.5.1.
. 2.6.5.1. !
!
FLIP
FLIP

AT89C51ED2
AT89C51ED2 ()
()

) )

) )

284 285
RS232 RS232 (ISP)

IDE, , 
. 1.3.9.1, RS232 (COM 1) USBDEBUG,
USB .

2.6.6.1.
. 2.6.5.1. C8051F067
!
C8051F067 
FLIP
TQFP64PGA64 (. . 1.3.9.3) 
(. 1.3.9.1). P1P3 ,
AT89C51ED2 C8051F067 ( 23 3 ).
()
P4 , 
( 23).
IDE.
, (. 2.6.6.1.1,).
Options () Connection options ( 
) (. 2.6.6.1.1,) USB Debug Adapter,
JTAG OK (. 2.6.6.1.1,). , ,
Connect ( ) (. 2.6.6.1.1,), 
Ready (),
Target: C8051F067, , C8051F067
) (. 2.6.6.1.1,).
*.hex  .
DEBUG 
Erase () Blank Chek ( Download Object File ( ) (. 2.6.1.1,). 
) , ( (, inrsf067.hex), 
Program () Verify (); (. 2.6.1.1,, ) Download () (. 2.6.1.1,).
RUN () (. 2.6.5.1,). inrsf067.hex, 
(. 2.6.5.1,). :
FLIP (. 2.6.5.1,) 
( Hello.clw). Downloadinng: D:\.\inrsf067.hex
, FLIP  Download sucsessful.
, . Checksum: 0x9204
Win'98 Win'XP ( . . 115 200 ). () 
. , inrsf067.hex (. 2.6.1.1,).
Disconnect ( ),
2.6.6. C8051F067 DEBUGAdapter (. 2.6.1.1,); 
C8051F330D ISP C2 JTAG Target: C8051F067 : Target:
RS232 C8051FXXXX; (. 2.6.1.1,); , USBDEBUG 
. , USBDEBUG .
C8051F067 
C8051F330D P4 , 
(. 1.3.9.1).  RS232 ( 12).
. Silicon Laboratories IDE v.2.5.2 USBDEBUG  
60 . , Hello.clw.
IDE C8051F067 C8051F330D,
. 1.3.9.1.

286 287
RS232 RS232 (ISP)

. 2.6.6.1.1.
. 2.6.6.1.1.



8051F067
8051F067
()

) )

) )

288 289
RS232 RS232 (ISP)

. 2.6.6.1.1.
. 2.6.6.1.1.



8051F067
8051F067 ()
()

) )

) )

290 291
RS232 RS232 (ISP)

. 2.6.6.1.1.
. 2.6.6.1.1.








8051F067
8051F067
()
()

) )

) )

292 293
RS232 RS232 (ISP)

2.6.6.2.
C8051F330D
C8051F330D 
.
(. 1.3.9.1)  . 2.6.6.2.1.
C8051F067 ( ), !
C8051F330D (C8051F330P) DIP20 (DIP24),

P1P3 , C8051F330D (. . 
12 ). P4 , C8051F330D
( 23). ()
USBDEBUG,
USB a. RS232
COM 1 .
IDE.
. 2.6.6.1 :
1. . JTAG 
C2 (. 2.6.6.2.1,a). Connect (. 2.6.6.2.1,)
Target: C8051F330 (. 2.6.6.2.1, ).
2. , , :
inrsf330.hex (. 2.6.6.2.1,, ). )
,
, . . Disconnect.
C8051F330 C8051FXXXX, 
, . USBDEBUG
(. 2.6.6.2.1,e).
, P4 
, ( 12). 
( Hello.clw).

. 2.6.6.2.1.
!

C8051F330D

294 295
RS232 RS232 (ISP)

. 2.6.6.2.1.
! . 2.6.6.2.1.
!


C8051F330D
() C8051F330D
()

) )

296


, RS232
(ISP, ICP). 
? , RS232 ,  1. . . // . 1993. 2 . 5664.
, , 2. ..  . .:
? , ,1996.
RS232  3. :
, 2030,  . .: , 1988.
, , 20 , . . (t) 0,05 . 4. .. RS232: .
, .: , 2004.
, , 0,05 5. .. 3. // .
(1 ). ,  1996. 6. . 4041.
,  6. ..
.2. . // . 1996 3. C. 79.
RS232  7. ..
( ,  , . // . 1998.
, 10 ).  2. C. 1819.
,  8. .. MCS51
 , Analog Devices, Texas . //
Instruments, Philips, Atmel, Silicon Laboratories,  . 1997. 6. C. 3235; 1998. 7. C. 3436.
, RS232  9. .., .. . .: , 1993.
. ( )  10. ., . : 3 . / . . .: ,1993.
RS232 (,  11. .. : . .: , 1988.
, . Silicon Laboratories).
RS232 (. 2.4), 

12. www.analog.com
Win'98/XP.  13. www.atmel.com
. 14. www.maximic.com
15. www.semiconductorphilips.com
16. www.silabs.com
17. www.ti.com
18. www.msdn.microsoft.com/library
19. www.gapdev.com

298 299
1. RS232
COM 1
(data register). 3f8h.
. .
1) ,
1 2) RS232.

.
3fbh (. ) 80h. 3f8h
115 200 ,
RS232 3f9h . , 
( ), 
.
(interrupt enable register). 3f9h.
.1.1. RS232 . , 
, , 
25 (DB25), 9 (DB9)
.
1. RS232.
(. 1). 7 6 5 4 3 2 1 0
RS232
0 0 0 0
DB25 DB9 / :
0: 1 , .
Transmitter Data ( 1: 1 , .
2 3 TxD
) 2: 1 ERROR BREAK.
3 2 RxD Recivr Data ( ) 3: 1 CTS, DSR, RI, DCD.

4 7 RTS Request To Send ( ) , , 


( ,
5 8 CTS Clear To Send ( ) 3f9h), 7 3fbh (. ).
(interrupt identification register). 3fah.
6 6 DSR Data Set Ready ( )
. , 
:
7 5 SG Signal Ground ( )
Data Carrier Detect (
8 1 DCD
) 7 6 5 4 3 2 1 0
Data Terminal Ready ( 0 0 0 0 0
20 4 DTR
)
22 9 RI Ring Indicator ( ) 0: 1 .
1: 00: .
2: CTS,
.1.2. DSR, RI DCD.
RS232 ( 3feh . )
01: .
COM : COM 1 3f8h, COM 2 2f8h,
(3f8h).
COM 3 3e8h COM 4 2e8h.
10: .
COM 1
(3f8h).
.
300 301
RS232: 1. RS232

11: 7 6 5 4 3 2 1 0
( 3fdh). (),
(PE), (FE) :
BREAK (BI). 0: 1 .
(3fdh). (3f8h).
1: 1 . .
(line control register) . 3fbh. 2: 1 .
. (. . 3fdh).
, , 3: 1 .  .
, TxD . 4: 1 BREAK .
5: 1 .
7 6 5 4 3 2 1 0 6: 1 .
( )
: .
0: : 1, , .
1: 00 5, 01 6, 10 7, 11 8. 7: 1  .
2: : 0 1 , 1 2 .
3: (): (modem status register). 3feh.
4: X0, 01, 11. . 
5: : 1 = 0, 3 4 RS232.
11; = 1, 3 4 01.
6: BREAK . 7 6 5 4 3 2 1 0
1 TxD 0 (10 ) BREAK.
0 TxD 1 (+10 ). :
7: . 0: 1 CTS .
1 3f8h 3f9h. 1: 1 DSR .
0 3f8h 3f9h . 2: 1 RI .
3: 1 DCD .
(modem control register). 3fch. 4: 1 CTS (. 1).
. 5: 1 DSR (. 1).
DTR RTS RS232. 6: 1 RI (. 1).
7: 1 DCD (. 1).
7 6 5 4 3 2 1 0
0 0 0
:
0: 1 DTR . 1(+10), 0 . 0 (10).
1: 1 RTS . 1(+10), 0 . 0(10).
2: 1 OUT1 ( ).
3: 1 OUT2 ( ).
4: 1 TxD RxD .

(line status register). 3fdh.


.
RS232.

302
2.

8 . Analog Devices
24 ( 16 ) A ADS1210 . BurrBrown(TI)
2 (2 ). ( ) , 
,
.
.
, ( . . ) ( 
, ) RS232.

51 ,
.
. 
(), . ,
: MSDOS WINDOWS'98/XP.
. 2.1.
, . 2.1.2.
,
P80C552 AT89C51 
, :
1) ,
. 2.1.1.
, ,
2) ,
( ), (, )  3) (, 
( ) . . .),
(, , . .), ,
. 2.1.1. 4) ,
!

5) , 
: ,
, . .

.2.1.3.
3.1 :
...........................................................................................................0+5 ,
................................................................................................020 420 ,
, ,
.........................0,005 (10. )
()
................................................................................................ 0,0005 (16. ).
.
, 3.2. ..................................................................................8.
RS232 ( COM 1 COM 2).  3.3. :
1500 . ........................................................................................................0,110000 ,
 ......................................................................................165536.
. 16 (24) , ..................................................................0,053000 .
8 8 (16) , ,  : ..........................................................8 ( 16. )
.  ................................................................................................ 8 15 ( 10. ).
P80C552 (. Philips) 10 8  3.4. : ....................................................................1,
(1 ) 89S8252 (. ATMEL)  .......................................................................1.

304 305
RS232: 2.

TTL. . . 2.1.7.1.
. ,

3.5. : .......................9600 115 200 . (O DOS) ():
3.6. , : 30208 ( CD e note ;
book, 40x60x9,5 ( Slim), 40x60x8 ( Super Slim), 40x60x7,5
;
( Work Station) .
3.7. : ...........................................................................................220 15 .
3.8. : ......................................................... .

. 2.1.4. -
, 
,
, . . ,  )
. 
.

. 2.1.5.
.

. 2.1.6.
( ) 
( ), / ( ),
, ( ), (2
), . ( ), ( ), ( ),
( ), ( ) .

. 2.1.7. , )
( DOS)
. . 2.1.7, , 
. Clarion v.3.100 
(Graphic User Interface GUI3) DOS. 
, ,
. .2.1.7.1,. 
.
. . 2.1.7.
,

(O DOS):

)
306 307
RS232: 2.

. . 2.1.7.1. . . 2.1.7.1.
, ,

(O DOS) (O DOS) ():
(): ;
(
; );

( );

) )

) )

) )

308 309
RS232: 2.

. 2.1.8. . . 2.1.8.2.
89C51 ADS1210 WINDOWS'XP,
Windows98/XP
Clarion v.6.0:
. . 2.1.8.1, , (  a
( COM 2,
), Windows98, . . 2.1.8.2, , WindowsXP.
115 200 )
. . 2.1.8.1. (10 )
;
:

( COM 1, ,
(
9600 ) )
(10 );

;
)
( !
). !
!
)

. 2.1.9.
. . 2.1.9.1 ) )
 (). 
Slim. 2000 . 

.

310 311
RS232: 2.

. . 2.1.9.1. . . 2.1.9.1.



! !
(). ( (). (


Slim.) Slim.)

2000 . 2000 .
()

) )

) )

312 313
RS232: 2.

. . 2.1.9.1. . . 2.1.9.2.



! ().
(). ( (

CD.)
Slim.) 1995 .
()
2000 .
()

) )
. . 2.1.9.2, 
(). CD.
1995 . .
. . 2.1.9.2.




().
(


CD.)
1995 .

) )

314 315
RS232: 2.

. . 2.1.9.2. 0,001 (

!).
ADR293
. Analog Devices Inc., , 
().
( ,
MAX4507 .
MAXIM, 36
CD.)
1995 . 40 ; MAX4507 
() ( +24 ), . .
,
, ( 
, 2,5 )
( ) iCoupler ADuM1201 . Analog
Devises Inc.,
;
(RS232), 
115 200 ,
, ( 
).

2 : 1) 
) (MSC1210) 2) .
C,
( 
. 2.1.10. (2005 .) C51 V6.14 . Keil Software).
2005 . , 
 : , Windows98 (SE2)
( Analog Devices Inc., Texas Instruments, MAXIM .). WindowsXP(SP2) ( Clarion V6.0).
MSDOS(V7.X),
Windows98(SE2) WindowsXP(SP2). RS232, 
. / RS232 (in out). , 
MSDOS Windows98 , WindowsXP 
. ( ). WindowsXP 
, , : WindowsXP,
.
( 3  
) 51 MSC1210Y5 . Texas 
Instruments, , , : 12 ,
24 8 , 3 .
,  : (. . 2.1.9.1.)
() 120 ; , ,
 0,001 ( , . 
0,0003 ), .
;  .
,  ( 

316 317
RS232:

. . 2.1.9.1 . 2.1.9.2 ). 
( ).
, 
. : MSDOS WIN
DOWS'98/XP.

. 2.1.11.
( 2005 .)
.
AT89C51ED2 . ATMEL, 
 Burr Brown (Ti), 16
16 , /

, / 82C54, 
/.  7 1952 ., (1982 .),
. ADUM1201; 
MAX4507 1975 . .
MAXIM. :
() ()
, ,
51 .
email: compmicrosys@mail.ru
http://www.compmicrosys.ownsite.ru

319