12.07.2015 Views

80C186EB/80C188EB Microprocessor User's Manual - CEUNES

80C186EB/80C188EB Microprocessor User's Manual - CEUNES

80C186EB/80C188EB Microprocessor User's Manual - CEUNES

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$mod186nameexample_master_select_slave;**************************************************************;; select_slave;; 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 xxxxhP1CON equ xxxxh ;Port 1 Control registerP2CON equ xxxxh ;Port 2 Control registerS1CON equ xxxxh ;Serial Port 1 Control registerS1STS equ xxxxh ;Serial Port 1 Status registerS1TBUF equ xxxxh ;Serial Port 1 Transmit BufferS1RBUF equ xxxxh ;Serial Port 1 Receive Bufferlib_80186public_select_slavesegment public 'code'assume cs:lib_80186_select_slaveproc farpush bp ;save caller's bpmov bp, sp ;get current top of stack;get slave address off the stack_slave_addr equ word ptr [bp+6]push cx ;save registers that will bepush dx ;modifiedmov dx, P1CON ;Get state of port 1 controlsin ax, dxand ax, 0f0h ;make sure P1.0:3 is portout dx, almov dx, P2CON ;set Port 2.1 for TXD1, P2.0 RXD1mov ax, 0ffhout dx, alExample 10-4. Master/Slave — The _select_slave Routine10-30

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

Saved successfully!

Ooh no, something went wrong!