advertisement
B
Range (hex)
200 - 207
208 - 20F
2E8- 2EF
* 2F8 - 2FF (COM2)
3E8 - 3EF
* 3F8 - 3FF (COM1)
●
●
●
●
●
1
O
O
●
O
●
O
O
2
Switch position
3 4
O
O
O
O
●
●
●
●
●
●
●
● ●
●
●
O
●
5
O
O = 0n ● = 0ff * = defaults
NOTE: Switches 1-6 control the PC bus address lines as follows:
0
●
●
O
0
6
O
1
A3
2 3
A4 A5
4
A6
5 6
A7 A8
Interrupt level-lRQ (JP2 and JP3)
You can set each port for any interrupt level from 3 to 9, except 8. Jumper JP2 controls Ch. 1, and JP3 controls Ch.
2. Simply short the pins on the jumper corresponding to the interrupt level (see figure below).
JP2 (Ch 1, COM1) IRQ JP3 (Ch, 2, COM2) IRQ
Connector pin assignments
You access the PCM-361 0’s ports through two extemal male DB-9 connectors. Ground pins are not connected to the DB-9 connector housing for the sake of isolation. With channel 1 you must attach the external cable to the proper proper connector (JP7 or JP8) depending on whether you are using RS-232 or RS-485. See page 2 for details.
RS-422/485 pin assignments appear below:
RS~22
7
8
5
6
9
3
4
1
2
TX-(DATA-) or send data - (DTE)
TX+(DATA+) or send data + (DTE)
RX+ or receive data + (DTE)
RX- or receive data - (DTE)
GROUND
RTS- or ready to send -
RTS+ or ready to send +
CTS+ or clear to send +
CTS- or clear to send -
RS-232 pin assignments appear below:
If you use the ports as standard COM1 and COM2, you will need to set Channel 1 to IRQ 4 and Channel 2 to IRQ 3.
Note: If your CPU module or card has serial intefface ports, you wiD need to adjust the 1/0 port addresses (or disable the ports) to avoid conflicts.
7
8
5
6
9
3
4
1
2
GND
DSR
RTS
CTS
Rl
DCD
RD
TD
DTR receive line signal detector received data transmitted data dataterminal ready ground data set ready request to send clear to send ring indicator
PCM-3610 User's Manual 3
Hardware installation
Warning!
TURN OFFyour PC power supply whenever you instaR or remove the
PCM-3610 or connect and disconnect cables.
Installing the module on a CPU card
1. Tum the PC’s power off. Tum the power off to any peripheral devices such as printers and monitors.
2. Disconnect the power cord and any other cables from the back of the computer.
3. Remove the system unit cover (see the user’s guide for your chassis if necessary).
4. Remove the CPU card from the chassis (if necessary) to gain access to the card’s PC/104 connector.
5. Screw the brass spacer (included with the module) into the threaded hole on the CPU card. Do not tighten too much, or the threads may be damaged.
6. Carefully align the pins of the PCM-3610 with the
PC/ 104 connector. Slide the module into the connector. The module pins may not slide all the way into the connector; do not push too hard or the module may be damaged.
7. Secure the module to the CPU card to the threaded hole in the CPU card using the included screw.
8. Attach any accessories to the PCM-3610.
9. Reinstall the CPU card and replace the system unit cover. Reconnect the cables you removed in step 2.
Tum the power on.
Connecting to another PC/104 module
1. Insert the pins of connector JP6 (on the end of the
PCM3610 module) into the piggyback connector on the other PC/104 module.
Signal wiring
4
5
2
3
6
7
RS-422 has separate transmit and receive lines so both devices can transmit at the same time. The transmit lines from one device connect to the receive lines on the other device. Typical connections are as follows:
Computer A
1 TX-
Computer B
4 RX-
TX+
RX+
RX-
GND
RTS-
RTS+
3
2
1
5
9
8
RX+
TX+
TX-
GND
CTS-
CTS+ .
8
9
CTS+
CTS-
7
6
RTS+
RTS-
In RS-485 the two devices share a single pair of data lines.
One device transmits while the other receives. Typical connections are as follows:
2
5
Device A
1 TX- (DATA-)
TX+ (DATA+)
GND
Device B
1
2
5
TX- (DATA-)
TX+ (DATA+)
GND
Programming
Programming with COM1 or COM2
If you set the PCM-3610's ports as COM1 and COM2, you can send and receive data using the nommal communication functions found in high-level languages. The following examples use BASIC to demonstrate PCM-3610 programming.
The BASIC communication process starts with the OPEN
~COMn: , , ..." statement. This statement assigns a buffer for communication purposes and sets up the communication parameters.
2. Screw the PCM-3610 to the brass spacer.
This completes the hardware installation. Install the software driver as described in the following section.
Command format
OPEN "COMn: [speed][,parity][,data][,stop]
[,RS][,CS[n]][,DS[n]][,CD[n]][,LF][,PE]"
AS [#]filenum
Example:
OPEN "COM1:9600,N,8,,CS,DS,CD" AS #1
Where:
COMn: n is 1 or 2, indicating either COM1 or COM2 speed: An integer constant specifying the baud rate in bits per second
4
PCM-3610 User's Manual
RS:
CS:
DS:
CD:
LF: parity: One of the following characters:
S: space
0: odd
M: mark
E: even
N: none data: stop:
An integer constant indicating the number of data bits. Valid values are 4, 5, 6, 7 and 8. The default is 7.
The number of stop bits. Valid values are 1 and 2.
The default is 2 for 75 and 110 bps, 1 for all others.
Suppresses RTS
Controls CTS
Controls DSR
Controls CD
Sends a line feed following each carriage return
PE: Enables parity checking filenum: filenum is an integer expression which evaluates to a valid file number
You must put the speed, parity, data and stop parameters in this position and order, but you can put the RS, CS, DS, CD,
LF and PE parameters in any order. The n argument in the
CS, DS and CD parameters specifies the number of milliseconds to wait for the signal before returning a “device timeout” error. n may range from 0 to 65535. If you omit n I; or set it equal to 0, then the line status is not checked at all.
Refer to the IBM BASIC reference manual for more detailed information.
240
250
260
270
300
180
190
200
210
220
230
310
320
330
340
350
360
50
60
70 hO
80
10
20
30
40
90
100
110
120
130
140
150
160
170
Programming example—standard COM ports
You can use the following BASIC program to test the PCM-
3610's send and receive functions.
\**************************************************
\* Program: DEMO01.BAS (for RS485 mode) *
\* Description: This demo program transmits a
\* string through COM1 and receives it through
*
*
\* COM2
\*
\* Jumper settings
*
*
*
\* JP4: RS485, JPS: RS485
\* JP10: RS485/RS422
\*
\* Signal wiring
\* COMl
\* 1 TX- (DATA-)
\* 2 TX+ (DATA+)
\* 5 GND
< - - - >
< - - - >
< - - - >
COM2
1 TX- (DATA-)
2 TX+ (DATA+)
5 GND
*
*
*
\**************************************************
*
*
\Set the proper parameters
\COM1 L COM2: baud rate=9600 ; no parity check;
*
*
*
\Data bit=8; stop bit=1
\Ignore the CTS, RTS and DSR signals.
OPEN "COM1:9600,N,8,1,RS,CS,DS,CD" FOR RANDOM AS #1
OPEN "COM2:9600,N,8,1,RS,CS,DS,CD" FOR RANDOM AS #1
INPUT "INPUT COMMAND:":CMD$
IF CMD$="Q" OR "q" THEN CLOSE:END ELSE GOSUB 250
GOSUB 300:GOTO 220
\****** Transmit data sub-routine ******
PRINT #1, CMD$
RETURN
\****** Receive data sub-routine ******
T=TIMER:TEMP$="":RX$=""
IF TIMER>T+.5 THEN PRINT "TIMEOUT ERROR":RETURN
IF LOC(2)>0 THEN TEMPS=INPUT$(1,#2) ELSE GOTO 320
RX$=RXS+TEMP
IF TEMP$=CHR$(13) THEN GOTO 360 ELSE GOTO 320
PRINT "RECEIVE DATA:";RX$:RETURN
PCM-3610 User's Manual
Using other 1/0 port addresses
If you are going to use l/O ports other than COM1 or
COM2, you will need to directly program the registers of the i-~ PCM3610’s 16C550 chip.
560
570
580
590
520
530
540
550
480
490
500
510
440
450
460
470
600
610
620
400
410
420
430
360
370
380
390
320
330
340
350
280
290
300
310
240
250
260
270
200
210
220
230
160
170
180
190
12 0
130
140
150
10
20
30
80
90
100
110
40
50
60
70
See page 7 for information on the fommat and programming of these registers. See page 8 if you have trouble finding a
~. free l/O port base address.
You can use the following program as a base as you develop your own driver. The program exchanges data (the numbers 0 to 256) between two ports. It uses l/O port addresses hex 2E8 and 3E8. Set JP4, JP5 and JP10 for
RS485 or RS-422 mode (described on page 2).
Programming exampleÑarbitrary 1/0 ports
\****************************************
\Clear the screen
CLS
\Set the I/O port base addresses for
\both cards
PORT1%=hH2E8
PORT2%=hH3E8
\Read all registers once to
\clear any random data
FOR I=PORT1% TO PORT1%+6
DUM=INP(I)
NEXT I
FOR I=PORT2% TO PORT2%+6
DUN=INP(I)
NEXT I
\Initialize the registers of tportl. First, set DLAB = 1 so the
\desired baud rate can be programmed.
OUT PORT1%+3,&H80
\Write the value of divisor into
\registers: hex 180 = dec 384 = 300 BAUD
OUT PORT1%,&H80:0UT PORT1%+l,&H1
\Set word length = 8 bits, stop bits = 2,
\even parity, DLAB = 0.
OUT PORT1%+3, hHlF
\Do the same thing for port2.
OUT PORT2%+3,hH80
OUT PORT2%,hH80:0UT PORT2%+1,&H1
OUT PORT2%+3,&H1F
\Loop over data (0-255) and send it
\from portl to port2
FOR BYTE=0 TO 255
\Wait until the transmitter buffer
\is empty.
IF (INP (PORT1%+S) AND 32) =0 GOTO 350
\Output the data through portl.
OUT PORT1%,BYTE
\See if the data is available by checking
\the Data Ready bit.
IF (INP(PORT2%+5) AND 1)=0 GOTO 400
J=INP(PORT2%)
\Print out the data byte received
PRINT ~port ":HEX$(PORT2%)" = ":HEX$(J)
\If the value sent <> the received value then error
IF J<>BYTE GOTO 620
NEXT BYTE
\Loop over data (0-255) and send it
\from port2 to portl.
FOR BYTE=0 TO 255
\See if the transmitter buffer is empty.
IF (INP(PORT2%+5) AND 32)=0 GOTO 510
OUT PORT2%,BYTE
\See if the data is available by
\checking the Data Ready bit.
IF ( INP ( PORT1%+S) AND 1 ) =0 GOTO 550
J=INP(PORT1%)
PRINT "port":HEXS (PORT1%)"= ":HEXS (J)
IF J<>BYTE GOTO 620
NEXT BYTE
\If everything is OK, then stop.
END
PRINT "Data transmission error!":BEEP:END
5
Programming exampLE—communication
The following pair of example programs show how you can set up communication between two computers. The first program sends data then receives data. The second program receives data then sends data. Run the first program on one computer and the second on another.
Program for first computer
260
270
280
290
300
310
320
330
18 0
190
200
210
220
230
240
250
90
100
110
120
130
150
160
170
50
60
70
80
10
20
3 0
40
\************ STEP 1: INITIALIZATION ************
\Clear screen
CLS
\Define variables A to Z as integer
DEFINT A-Z
\Set port base address (must match hardware)
PORT = &H3FB
\Set baud rate to 300
OUT PORT + 3, LH80
OUT PORT, LH80
OUT PORT, 1
OUT PORT + 3, LH1F
\******** STEP 2: SEND DATA ********
FOR I = 65 TO 90
\
GOSUB 200
NEXT I
GOTO 260
STATUS = INP(PORT + 5) AND &H20
IF STATUS = 0 THEN 200
OUT PORT, I
FOR J = 0 TO 1200: NEXT J
RETURN
\****** STEP 3: RECEIVE DATA ******
FOR I = 65 TO 90: GOSUB 280: NEXT
END
STATUS = INP(PORT + 5)
IF (STATUS AND LH1E) THEN 280
IF (STATUS AND LH1) = 0 THEN 280
D = INP(PORT)
PRINT "DATA= "; CHR$ (D)
RETURN
I
Program for second computer
250
260
270
280
290
300
310
320
170
180
190
200
210
220
230
240
3 3 0
340
3 50
90
100
110
120
130
140
150
160
50
60
70
80
10
20
3 0
40
\********** STEP1: INITIALIZATION **********
\Clear screen
CLS
\Define variables A TO Z as iDteger
DEFINT A-Z
\Set port base address (must match hardware)
PORT = LH2F8
\Set baud rate to 300
OUT PORT + 3, LH80
OUT PORT, &H80
OUT PORT, l
OUT PORT + 3, &HlF
\***** STEP 2: RECEIVE DATA FROM ANOTHER PC *****
FOR I = 65 TO 90: GOSUB 190: NEXT I
PRINT: PRINT: PRINT
PRINT.DATA RECEIVES END, THEN DATA SEND BEGINNING."
PRINT: PRINT "PRESS ANY KEY. . ."
IF INXEY$ = "" THEN 180 ELSE 260
STATUS = INP(PORT + 5)
IF STATUS AND LH1E THEN GOTO 190
IF (STATUS AND LH1) = 0 THEN 190 d = INP(PORT)
PRINT "DATA= ": CHR$(d)
RETURN
\*************** STEP 3: SEND DATA ***************
FOR I = 65 TO 90 d = I
GOSUB 310
NEXT I
END
STATUS = INP(PORT + 5) AND LH20
IF STATUS = 0 THEN 310
OUT PORT, d
FOR J = 0 TO 1200: NEXT J
RETURN
C language test program
You can use the following C program to test the PCM-
3610's send and receive functions.
/***************************************************/
/* Program: DEMO01.C (For RS485/RS422) */
/*
/*
Description: This demo program transmits a string to COM1 and receives a string Erom COM2
*/
*/
/*
/*
/*
/*
Compiler: Turbo C 2.0
/*
/’
/’
/’
RS-485 jumper and switch settings, signal wiring
SW1 3F8 COM1: COM2: sW2 2F8
JP2 IRQ4
1 DATA-
2 DATA+
<—>
<—>
1 DATA-
2 DATA+
/’
/’
JP3 IRQ3
JP4 485
JP5 -
JP10 -
485
485/422
5 GND <—> 3 GND
*/
*/
/’
/’
/’
/’
/’
/’
/’
/’
/’
RS-422 jumper and switch settings, signa1 wiring
SW1 sW2 2F8
JP2 -
JP3 IRQ3
JP4 -
JP5 422
JP10 -
3F8
IRQ4
422
485/422
COM1:
1 TX-
2 TX+
3 RX+
4 RX-
5 GND
<—>
<—>
<—>
<—>
<—>
COM2:
4 RX-
3 RX+
2 TX+
1 TX-
3 GND
*/
*/
*/
*/
*/
*/
*/
*/
*/
/***************************************************/
*/
*/
*/
*/
*/
*/
*/
*/
#include <dos.h>
#include <io.h>
#include <stdio.h>
#include <conio.h>
#define TIME_OUT 10000 static static ste~tic static int base0 = 0x3f8; int basel = 0x2f8;
/* Base address of port 0 */
/* Base address of port 1 */ char rec[l6]: /* Buffer for received string ‘/ char cmdll61 i /* Buffer for transmitted string / void main ( )
{ int i; /* Counter for character being sent/received */ char flag; /* Flag for end of output/input data */ int timeout; /* Timeout counter */ outport ( (baseO+2), 0xc9); /* enable port 0 FIFO */ outport((basel+2), 0xc9); /* enable port 1 FIFO */
/* set communication parameters for port 0 */ outp(baseO+3, 0x80) i /* Set DLAB=1 */
/. Set baud = 115200 */ outp(baseO, 0x01);
/* Set data=8, stop=1, no parity */ outp(baseO+3, 0x03);
/* Disable port 0 interrupt */ outp(baseO+1, 0x00);
/* Set communication parameters for port 1 */ outp(basel+3, 0x80) 1 /* Set DLAb=1 */
/* Set baud = 115200 */ outp(basel, 0x01);
/* Set data=8, stop=1, no parity */ outp (basel+1, 0 ); outp(basel+3, 0x03 );
/* Disable port 1 interrupt */ outp(basel+l, 0x00);
6
PCM-3610 User's Manual
printf("\nEnter ~ string to be transmitted "
"(1S characters or less) or Q to quit:"); gets (cmd); while (cmd[O] != "q" && cmd[0] != "Q")
{ i=O; cmd[strlen(cmd)] = 0xOd; flag=1; while (flag)
{ outportb(baseO, cmd[i] ); /* Send data */ i (cmd[i] == 0x0d) flag=o; i++;
} i=O; flag=1; timeout=TIME _ OUT; while (flag)
{
/* Check if receiver data is ready */ if ((inportb(basel+5) & 1) !=0)
{ rec [i]=inportb (basel ); /* Receive data */ if (rec[i] ==0x0d)
{ rec[i+1]='\O'; flag=0; printf ("\nReceived data: %s\n", rec);
} i++;
} else
{ /* Check timeout */ timeout--; if (timeout == 0)
{ flag = 0; printf("\nTimeout error\n");
}
}
} printf ("\nEnter a string to be transmitted "
}
}
"(15 characters or less) or Q to quit:"); gets (cmd);
PCM-3610 User's Manual
Register strcture and format
This section gives short description of each of the module’s registers. For more infommation please refer to the data book for the STARTECT 1 6C550 UART chip.
All registers are one byte. Bit O is the least significant bit, and bit 7 is the most significant bit. The address of each register is specified as an offset from the port base address
(BASE), selected with DIP switch SW1 or SW2.
DLAB is the "Divisor Latch Access Bit", bit 7 of BASE+3.
BASE+0 Receiver buffer register when DLAB=0 and the operation is a read.
BASE+O Transmitter holding register when DLAB=0 and the operation is a write.
BASE+O
BASE+1
Divisor latch bbs 0 - 7 when DLAB=1.
Divisor latch bHs 8 -15 when DLAB=1.
The two bytes BASE+O and BASE+1 together fomm a 1 6-bit number, the divisor, which detemmines the baud rate. Set the divisor as follows:
BASE+1
BASE+2
1800
2000
2400
3600
4800
7200
9600
19200
5 0
7 5
110
133.5
150
300
600
1200
38400
56000
115200
2 4
1 6
1 2
6
6 4
5 8
4 8
3 2
3
2
1
768
384
192
9 6
2304
1 536
1047
857
Interrupt Status Register (ISR) when
DLAB=0 bit 0 Enable received-data-available interrupt bit 1 bit 2
Enable transmitter-holding-registerempty interrupt
Enable receiver-line-status bit 3 interrupt
Enable modem-status interrupt
FIFO bit 0 bit 1 bit 2
Control Register (FCR)
Enable transmit and receive FlFOs
Clear contents of receive FIFO
Clear contents of transmit FIFO
7
BASE+3
BASE+4
BASE+5
BASE+6
BASE+7 bit 3 Change RXRDY and TXRDY from mode O to mode 1.
bits 6-7 Set trigger level for receiver FIFO interrupt.
Standard PC I/O port assignments
The following chart shows the l/O addresses used by standard PC peripheral devices.
1
1
O
0
0
1
0
1
0 1
0 4
0 8
1 4
Line Control Register (LCR) bit 0 bit 1
Word length select bit
Word length select bit 1
1
1
O
0
0
1
O
1
7
8
5
6 bit 2 bit 3 bit 4 bit 5 bit 6 bit 7
Number of stop bits
Parity enable
Even parity select
Stick parity
Set break
Divisor Latch Access Bit (DLAB)
Modem Control Register (MCR) bit 0 DTR bit 1 RTS
Line Status Register (LSR) bit 0 Receiver data ready bit 1 bit 2 bit 3
Overrun error
Parityerror
Framing error bit 4 bit 5 bit 6 bit 7
Break interrupt
Transmitter holding register empty
Transmitter shiff register empty
At least one parity error, framing error or break indication in the FIFO
Modem Status Register (MSR) bit 0 Delta CTS bit 1 bit 2
Delta DSR
Trailing edge ring indicator bit 3 bit 4 bit 5 bit 6 bit 7
Delta received line signal detect
CTS
DSR
Ri
Received line signal detect
Temporary data register
000-1 FF
200
201
202-277
280-2F7
2F8-2FF
300-377
378-37F
380-3AF
3C0-3CF
3D0-3DF
3E0-3EF
3F8-3FF used by base system board not used game control not used 278-27F second printer port not used
COM2 not used printer port not used 3B0-3BF monochrome adapter and printer not used color and graphics adapters not used 3F0-3F7 floppy diskette drive
COM1:
8
PCM-3610 User's Manual
advertisement
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project