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

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

SERIAL COMMUNICATIONS UNIT<br />

11.5.2 Mode 0 Example<br />

Example 11-2 shows a sample Mode 0 application.<br />

$mod186<br />

name<br />

example_SCU_mode_0<br />

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

; FUNCTION: This function transmits the user's data, user_data, serially<br />

; over RXD1. TXD1 provides the transmit clock. The transmission frequency<br />

; is calculated as follows:<br />

;<br />

; tran_freq = (0.5*CLKIN/BAUDRATE)-1<br />

;<br />

; A 0-1-0 pulse on P1.0 indicates the end of transmission.<br />

;<br />

; SYNTAX: extern void far parallel_serial(char user_data,int tran_freq)<br />

;<br />

; INPUTS: user_data - byte to send out serially<br />

; tran_freq - baud rate compare value<br />

; OUTPUTS: None<br />

; NOTE: Parameters are passed on the stack as required by high-level<br />

; languages.<br />

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

B1CMP equ xxxxH ;Channel 1 Baud Rate Compare<br />

S1CON equ xxxxH ;Channel 1 Control<br />

S1STS equ xxxxH ;Channel 1 Status<br />

S1TBUF equ xxxxH ;Channel 1 Receive Buffer<br />

;xxxx - substitute register offset<br />

;Example assumes that all the port pins are configured correctly and<br />

;PCB is located in I/O space.<br />

lib_80186 segment public 'code'<br />

assume cs:lib_80186<br />

public<br />

_parallel_serial<br />

_parallel_serialproc far<br />

push bp ;save caller's bp<br />

mov bp, sp ;get current top of stack<br />

user_data<br />

tran_freq<br />

equ word ptr [bp+6];get parameters off the stack<br />

equ word ptr [bp+8]<br />

push ax ;save registers that<br />

push dx ;will be modified<br />

mov dx, S1STS ;clear any pending exceptions<br />

Example 11-2. Mode 0 Example<br />

11-23

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

Saved successfully!

Ooh no, something went wrong!