;************************************************************************
; Output a byte to the serial port
;
; Arguments: W contains the character to send
; Returns: W contains the character sent
; Errors: None
;
;************************************************************************
Serial_Output:
movwf SerialBuf ; This is the value that will be shifted
movwf SerialTemp ; Saved for the return value
movlw 8
movwf BitCount ; Going to move 8 bits
bcf PORTA,TX ; Send the start bit
BitOutLoop:
call DelayForBaudPeriod
rrf SerialBuf,F
btfsc STATUS,C
bsf PORTA,TX
btfss STATUS,C
bcf PORTA,TX
decfsz BitCount,F
goto BitOutLoop
call DelayForBaudPeriod
bsf PORTA,TX ; Send stop bit, which is high
call DelayForBaudPeriod
return