;====================================================================== ; UART and Baud Rate initialization code (9_Nov_84) ;================================================== ; ; Copyright 1984 ; Morrow Designs, Inc. ; San Leandro, Ca. ; Written by David Block and Jim Kearney (September 1983) ; ;---------------------------------------------------------------------- ; Index (9_Nov_84) ;----------------- ; ; INIUART Initialize the Uart Main Line ; SETBAUD Determine the Baud Rate ; SETUART Set the Uart's Baud Rate ; INIT8 Set the Uart's Reciever/Transmitter Format PAGE ;---------------------------------------------------------------------- ; Uart Initialization ;-------------------- ; INIUART:JSR SETBAUD ;determine baud rate selection bits JSR SETUART ;setup UART for proper BAUD rate, etc JSR INIT8 ;set status of bit 8 parity, or mark, or space RTS ;---------------------------------------------------------------------- ; Determine the Baud Rate Settings ;--------------------------------- ; SETBAUD:LDA BDREG ;get current contents of baud register AND #$F9 ;Clear BD0 and BD1 STA BDREG LDA DIP1 ;get dipsw value AND #$03 ;get baud rate selection bits ASL A ;align with BDREG ORA BDREG ;set/clr baud bits STA BDREG ;Save it STA BAUD ;and set baud bits RTS PAGE ;---------------------------------------------------------------------- ; Set the Uart Baud Rate ;----------------------- ; SETUART:LDX #$80 ;after setting baud rate, wait to settle SULP1: DEX BNE SULP1 LDA #$80 ;reset USART STA S1STAT TAX TAX ;WAIT STA S1STAT LDA #$40 STA S1STAT ;Put USART in command mode LDA DIP1 ;get dip switch settings AND #%00001100 ;get the parity select bits ASL A ASL A ;align them for USART Mode byte STA TEMP ;put it aside LDA DIP1 ;get dip switch AND #%00000010 ;determine if it needs /16 or /64 LSR A ;move the determining bit over ORA TEMP ;get parity select bits back ORA #%01001110 ;OR in USART MODE boiler plate (8-data, 1-stop) STA S1STAT ;set USART Mode LDA #%00110111 ;get enable byte for USART STA S1STAT ;Enable USART STA UARTCMD ;save it in command instr. register LDA S1DATA ;Flush one character RTS ;---------------------------------------------------------------------- ; Set Transmission/Reception Format ;---------------------------------- ; INIT8: LDA DIP1 ;get dip setings LSR A ;get parity on/off status LSR A TAX AND #%00000001 STA PARSTAT ;save it in parity status TXA LSR A AND #%00000001 ;get whether mark or space/ odd/even STA BIT8 RTS PAGE END