Intel 80C188EC User Manual page 356

Hide thumbs Also See for 80C188EC:
Table of Contents

Advertisement

$mod186
name
;**************************************************************;
;
;
; FUNCTION: This function transmits a slave address, _slave_addr, over the
; serial network, with data bit 9 set to one. It then waits for the addressed
; slave to respond with its (slave) address. If this address does not match
; the originally transmitted slave address, or if there is no response within
; a set time, the function will return false (ax = 0). Otherwise, the function
; will return true (ax <> 0).
;
; SYNTAX:
extern int far select_slave(int slave_addr);
;
; INPUTS:
_slave_addr - address of the slave on the network
;
; OUTPUTS:
True/False
;
; NOTE:
Parameters are passed on the stack as required by high-level
;
languages. Example assumes that PCB is located in I/O space.
;**************************************************************
; substitute register offset in place of xxxxh
P1CON
equ
P2CON
equ
S1CON
equ
S1STS
equ
S1TBUF
equ
S1RBUF
equ
lib_80186
segment public 'code'
assume cs:lib_80186
public
_select_slave
_select_slave
proc far
push bp
mov
;get slave address off the stack
_slave_addr equ word ptr [bp+6]
push cx
push dx
mov
in
and
out
mov
mov
out
Example 11-4. Master/Slave — The _select_slave Routine
example_master_select_slave
select_slave
xxxxh
;Port 1 Control register
xxxxh
;Port 2 Control register
xxxxh
;Serial Port 1 Control register
xxxxh
;Serial Port 1 Status register
xxxxh
;Serial Port 1 Transmit Buffer
xxxxh
;Serial Port 1 Receive Buffer
;save caller's bp
bp, sp
;get current top of stack
;save registers that will be
;modified
dx, P1CON
;Get state of port 1 controls
ax, dx
ax, 0f0h
;make sure P1.0:3 is port
dx, al
dx, P2CON
;set Port 2.1 for TXD1, P2.0 RXD1
ax, 0ffh
dx, al
SERIAL COMMUNICATIONS UNIT
11-27

Advertisement

Table of Contents
loading

This manual is also suitable for:

80c186ec

Table of Contents