list p=16F88, r=DEC
errorlevel -302
#include <p16f88.inc>
__config _CONFIG1, _BODEN_OFF & _WDT_OFF & _LVP_OFF & _MCLR_OFF & _PWRTE_ON & _INTRC_IO
;----------------------
; DECLARE VARIABLES
;----------------------
cblock 0x20
tmp1
endc
;----------------------
; START
;----------------------
org 0
main
banksel CMCON
movlw 7
movwf CMCON ; CMCON = 7 set comperators off
banksel ANSEL
clrf ANSEL
banksel TRISA
clrf TRISA
clrf TRISB
banksel SPBRG
movlw 0x19 ; 0x19=9600 bps (0x0C=19200 bps)
movwf SPBRG
movlw b'00100100' ; brgh = high (2)
movwf TXSTA ; enable Async Transmission, set brgh
banksel RCSTA
movlw b'10010000' ; enable Async Reception
movwf RCSTA
; Provide a settling time for startup
banksel tmp1
clrf tmp1
settle
decfsz tmp1, f
goto settle
; Send a character through the UART
loop
movlw 'A'
call send
movlw 'B'
call send
goto $
;----------------------
; SEND function
;----------------------
send
banksel TXREG
movwf TXREG ; Send data which has been stored in W
trans_wt
banksel TXSTA
btfss TXSTA, TRMT ; Loop until data is sent
goto trans_wt
return
end
UART-W0004: Attempt to receive data when Port pin direction for UART is set to an output (0).
by Jake Hertz
by Duane Benson
by Jake Hertz