03.01.2015 Views

80C186EC/80C188EC Microprocessor User's Manual

80C186EC/80C188EC Microprocessor User's Manual

80C186EC/80C188EC Microprocessor User's Manual

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

SERIAL COMMUNICATIONS UNIT<br />

$mod186<br />

name<br />

example_master_slave<br />

;*******************************************************************<br />

; FUNCTION: This function demonstrates how to implement the three<br />

; master/slave routines (_slave_1, _select_slave, and _send_slave_command)<br />

; in a typical setup.<br />

;<br />

; NOTE: It is assumed that the network is set up as shown in<br />

; Figure 11-18, that the slave unit is running the<br />

; _slave_1 code, and that the PCB is located in I/O space.<br />

;<br />

;*******************************************************************<br />

Slave1 equ 01h ;address assigned to slave unit 1<br />

Flash equ 01h ;command to flash EVAL board LEDs<br />

Disc equ 0fh ;command to disconnect from network<br />

False equ 00h<br />

lib_80186<br />

extrn<br />

extrn<br />

lib_80186<br />

code<br />

segment public 'code' ;declare external routines<br />

_select_slave:far<br />

_send_slave_cmd:far<br />

ends<br />

segment public 'code'<br />

assume cs:code<br />

public<br />

_main<br />

_main<br />

proc near<br />

push Slave1 ;get slave unit 1 address<br />

;send the address over the network<br />

call far ptr _select_slave<br />

add sp, 2 ;adjust sp<br />

cmp ax, false ;was slave 1 properly selected <br />

je SlaveExit ;no: then exit<br />

push Flash ;yes: then send Flash command<br />

;send it<br />

call far ptr _send_slave_cmd<br />

add sp, 2 ;adjust sp<br />

;insert a delay routine to allow completion of last command<br />

;send it<br />

SlaveExit:<br />

_main<br />

code<br />

push Disc ;prepare to disconnect slave<br />

call far ptr _send_slave_cmd<br />

add sp, 2 ;adjust sp<br />

ret<br />

endp<br />

ends<br />

end _main<br />

Example 11-3. Master/Slave — Implementing the Master/Slave Routines<br />

11-26

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!