AN503

Product: Domino 2

Accessing the Coprocessor I/O

Date: 7/28/99

Introduction: This application note presents a program in Basic-52 that uses the Domino IIís coprocessor digital inputs and outputs.
 

Background: One of Domino IIís features is the 16 bits of I/O available through itís coprocessor, which offer:

20-mA source per pin.

25-mA sink per pin.

Bit or port programmable.

While using the coprocessor is straight forward, it does require a series of instructions which are easier to use than adding an external I2C I/O expansion IC to the Domino I.

 

How it works: The coprocessor communicates with the processor via the I2C bus. It accepts an I2C instruction through built in routines in Domino Utilities. Each port and bit has itís own preset address. For example PORT Aís direction control is located at address 30H. Setting this bit makes all 8 bits of PORT A outputs. The following simple program illustrates using the coprocessors I/O by addressing each port.

 

Program Listing:

10 REM ** This program demonstrates how to operate the Domino 2's

20 REM ** Coprocessor I/O's. It will allow you to set each port

30 REM *** as inputs or outputs and allow you to read the inputs

40 REM *** and set the outputs.

50 ?"Menu"

60 ?"1 - Set PORT A direction register as inputs"

70 ?"2 - Set PORT B direction register as inputs"

80 ?"3 - Set PORT A direction register as outputs"

90 ?"4 - Set PORT B direction register as outputs"

100 ?"5 - Read PORT A's inputs"

110 ?"6 - Read PORT B's inputs"

120 ?"7 - Set PORT A's outputs"

130 ?"8 - Set PORT B's outputs"

140 INPUT A

150 IF A=1 THEN GOTO 240

160 IF A=2 THEN GOTO 290

170 IF A=3 THEN GOTO 340

180 IF A=4 THEN GOTO 390

190 IF A=5 THEN GOTO 440

200 IF A=6 THEN GOTO 520

210 IF A=7 THEN GOTO 580

220 IF A=8 THEN GOTO 650 ELSE GOTO 50

230 REM *** Setting PORT A as inputs.

240 R = 30H

250 DT = 0FFH

260 GOSUB 11000

270 GOTO 50

280 REM *** Setting PORT B as inputs.

290 R = 33H

300 DT = 0FFH

310 GOSUB 11000

320 GOTO 50

330 REM *** Setting PORT A as outputs.

340 R = 30H

350 DT = 0H

360 GOSUB 11000

370 GOTO 50

380 REM *** Setting PORT B as outputs.

390 R = 33H

400 DT = 0H

410 GOSUB 11000

420 GOTO 50

430 REM *** Read PORT A's inputs.

440 R = 31H

450 GOSUB 10000

460 ?"The decimal value of PORT A is ":PH0. DT

470 G = GET

480 IF G=0 THEN 470

490 GOTO 50

500 REM *** Read PORT B's inputs.

510 R = 34H

520 GOSUB 10000

530 ?"The decimal value of PORT B is ":PH0. DT

540 G = GET

550 IF G=0 THEN 540

560 GOTO 50

570 REM *** Set PORT A's outputs.

580 ?"Please input the decimal number you want PORT A to be."

590 INPUT B

600 R = 32H

610 DT = B

620 GOSUB 11000

630 GOTO 50

640 REM *** Set PORT B's outputs.

650 ?"Please input the decimal number you want PORT B to be."

660 INPUT C

670 R = 35H

680 DT = C

690 GOSUB 11000

700 GOTO 50

9997 REM ***********************************************

9998 REM Coprocessor Read Routine

9999 REM

10000 PUSH 2000h + R

10010 CALL 0F12Ch

10020 POP DT

10030 IF DT>255 THEN PRINT "Communications error !!!"

10040 Return

10050 REM

10997 REM ***************************************************

10998 REM Coprocessor Write Routine

10999 REM

11000 PUSH 2000h + R,DT

11010 CALL 0F128h

11020 POP DT

11030 IF DT>255 THEN PRINT "Communications error !!!"

11040 Return

11050 REM

11060 REM ***************************************************280 REM *** Setting PORT B as inputs.

290 R = 33H

300 DT = 0FFH

310 GOSUB 11000

320 GOTO 50

330 REM *** Setting PORT A as outputs.

340 R = 30H

350 DT = 0H

360 GOSUB 11000

370 GOTO 50

380 REM *** Setting PORT B as outputs.

390 R = 33H

400 DT = 0H

410 GOSUB 11000

420 GOTO 50

430 REM *** Read PORT A's inputs.

440 R = 31H

450 GOSUB 10000

460 ?"The decimal value of PORT A is ":PH0. DT

470 G = GET

480 G = GET

490 IF G=0 THEN 480

500 GOTO 50

510 REM *** Read PORT B's inputs.

520 R = 34H

530 GOSUB 10000

540 ?"The decimal value of PORT B is ":PH0. DT

550 G = GET

560 G = GET

570 IF G=0 THEN 560

580 GOTO 50

590 REM *** Set PORT A's outputs.

600 ?"Please input the decimal number you want PORT A to be."

610 INPUT B

620 R = 32H

630 DT = B

640 GOSUB 11000

650 GOTO 50

660 REM *** Set PORT B's outputs.

670 ?"Please input the decimal number you want PORT B to be."

680 INPUT C

690 R = 35H

700 DT = C

710 GOSUB 11000

720 GOTO 50

9997 REM ***********************************************

9998 REM Coprocessor Read Routine

9999 REM

10000 PUSH 2000h + R

10010 CALL 0F12Ch

10020 POP DT

10030 IF DT>255 THEN PRINT "Communications error !!!"

10040 Return

10050 REM

10997 REM ***************************************************

10998 REM Coprocessor Write Routine

10999 REM

11000 PUSH 2000h + R,DT

11010 CALL 0F128h

11020 POP DT

11030 IF DT>255 THEN PRINT "Communications error !!!"

11040 Return

11050 REM

11060 REM ***************************************************