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

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 UNIT10.5 SERIAL PORT EXAMPLESThis section contains examples that show ways to use the serial port.NOTEThe examples assume that the Peripheral Control Block is located in I/O space.10.5.1 Asynchronous Mode ExampleExample 10-1 contains sample code to initialize Serial Port 0 for 9600-baud operation in asynchronousMode 4.$mod186namescu_async_example;;This file contains an example of initialization code for the <strong>80C186EB</strong>;Serial Communications Unit. The example has three procedures:;ASYNC_CHANNEL_SETUP sets up channel 0 as 9600 baud, full duplex,; 7 data bits+parity, with CTS# control.;ASYNC_REC_INT_PROC is an interrupt handler for a reception. The procedure; is nearly empty, since the code to perform error checking; and receive buffer handling is application dependent.;ASYNC_XMIT_INT_PROC is an interrupt handler for a transmission. This; procedure, too, is nearly devoid of code. A typical; application would test the TXE bit, then copy data from; the transmit buffer in memory to the S0TBUF register.;We assume serial port registers have been correctly defined and the PCB; is located in I/O space.B0CMP equ 0xxxx ;channel 0 baud rate compareS0CON equ 0xxxx ;channel 0 controlS0STS equ 0xxxx ;channel 0 statusS0RBUF equ 0xxxx ;channel 0 receive bufferS0TBUF equ 0xxxx ;channel 0 transmit bufferRI_TYPE equ xx ;receive is interrupt type 20TI_TYPE equ 21 ;transmit is interrupt type 21EOI equ 0ff02h ;end-of-interrupt registerSCUCON equ 0ff14h ;SCU interrupt control registercode_segassumesegment publiccs:code_segASYNC_CHANNEL_SETUP proc near;First, set up the interrupt handler vectorsxor ax,axmov ds,ax ;need DS to point to interrupt vector;table at 0hmov bx,RI_TYPE*4mov ax,offset ASYNC_REC_INT_PROCmov [bx],axmov ax, seg ASYNC_REC_INT_PROCmov [bx+2],axExample 10-1. Asynchronous Mode 4 Example10-23

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

Saved successfully!

Ooh no, something went wrong!