I am trying to have serial communication in 16F88 over hardware UART. However when i tried the code below, it just halt there and nothing happened.
I declared the temp1 as follows:
And the serial communication as follows:
with baud rate 9600. AmpHours as a 16 bits words.
I declared the temp1 as follows:
Code:
cblock 0x20
tmp1
endc
Code:
store_Ah:
mov16 dd+2,AmpHours
call Serial_sent
Serial_sent:
banksel SPBRG
movlw .25 ; 9.6kbps
movwf SPBRG
movlw b'00100100' ; brgh = high (2)
movwf TXSTA ; enable Async Transmission, set brgh
; Provide a settling time for startup
banksel tmp1
clrf tmp1
settle
decfsz tmp1, f
goto settle
; Send a character through the UART
loop
movf AmpHours, w
call Send
movf AmpHours+1, w
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