;************************************************************************* ; Jason Seelye ; ; Serial I/O subroutines for port A (port B similar) ; ; Created: 01/16/01 ; Modified: ;************************************************************************* $NOMOD51 ; omit assembler micro definitions $Include(reg515.inc) ; define 515 micro $Include(serial.inc) Name rs232 PUBLIC initcom,comin,_comout EXTRN DATA (SEIN) SERI SEGMENT CODE RSEG SERI ; switch to this code segment USING 0 ; use register_bank 0 ; ; INIT2681: Set up COM1 and COM2 for no parity, one stop bit ; and 8 data bits at 4800 baud MR1ADAT EQU 00010011B ; No RTS, Rx int on RxRDY, char mode, no parity, 8 data MR2ADAT EQU 00000111B ; normal, no TxRTS, no CTS, 1 stop bit initcom: ; Do reset commands for ports A and B. This will execute channel ; A miscellaneous commands numbered 101,100,011,010,001 clr P5.1 mov a,#01010000b ; Do from this command, down to 00010000 CRINIT: mov P2,#CRA movx @R1,A add a,#-16 jnz CRINIT mov P2,#MR1A ; set-up protocol for port A mov A,#MR1ADAT movx @R1,a mov a,#MR2ADAT movx @R1,a ;select baud rate mov P2,#ACR mov a,#80h movx @R1,a mov P2,#CSRA mov a,#10011001b ; set-up to 4800 baud movx @R1,a mov P2,#CRA mov a,#00000101b movx @R1,a RET comin: ; receive from port A mov P2,#SRA SERINA1: movx a,@R1 JNB ACC.0,SERINA1 MOV P2,#RHRA MOVX A,@R1 mov SEIN,A RET _comout: ; send out from port A MOV P2,#SRA SOUTA1: MOVX A,@R1 JNB ACC.2,SOUTA1 mov a,R7 MOV P2,#THRA MOVX @R1,a RET END