Hi, I'm facing a problem that the data program inside the PIC16F877A did not display out at hyperterminal. i'm using RS232 to USB converter connect with my laptop.
I have question :
1) i'm using window 7, i have already download hyperterminal software and use it. It is a problem that window 7 did not support the hyperterminal software so that it can't display out.
2) Below code i have build it succesfully. It's there anything wrong with the code that cause it did not display.
LIST P=16F877A
PROCESSOR 16f877a
#include <P16F877A.INC> ; Include header file
__CONFIG _CP_OFF & _DEBUG_OFF & _CPD_OFF & _LVP_OFF & _BODEN_OFF & _PWRTE_ON & _WDT_OFF & _XT_OSC
CBLOCK 0x20 ; Declare variable addresses starting at 0x20
dataL
ENDC
org 0x0000
goto START
org 0x0010
START
bsf STATUS,RP0 ; RAM PAGE 1
movlw b'00000000' ; set up TRISC
movwf TRISC
;Boot Baud Rate = 9600, No Parity, 1 Stop Bit
;
movlw d'129' ; 0x19=9600 bps (0x0C=19200 bps)
movwf SPBRG
movlw b'00100100' ; brgh = high (2)
movwf TXSTA ; enable Async Transmission, set brgh
bcf STATUS,RP0 ; RAM PAGE 0
movlw b'10010000' ; enable Async Reception
movwf RCSTA
; PROVIDE A SETTLING TIME FOR START UP
; ------------------------------------
;
clrf dataL
settle decfsz dataL,F
goto settle
movf RCREG,W
movf RCREG,W
movf RCREG,W ; flush receive buffer
;
; ---------
; MAIN LOOP
; ---------
;
call message ; send "16F628 alive"
loop call receive ; wait for a char
call send ; send the char
goto loop
;
; -------------------------------------------
; RECEIVE CHARACTER FROM RS232 AND STORE IN W
; -------------------------------------------
; This routine does not return until a character is received.
;
receive
btfss PIR1,RCIF ; (5) check for received data
goto receive
movf RCREG,W ; save received data in W
return
;
; -------------------------------------------------------------
; SEND CHARACTER IN W VIA RS232 AND WAIT UNTIL FINISHED SENDING
; -------------------------------------------------------------
;
send movwf TXREG ; send data in W
TransWt
bsf STATUS,RP0 ; RAM PAGE 1
WtHere
btfss TXSTA,TRMT ; (1) transmission is complete if hi
goto WtHere
bcf STATUS,RP0 ; RAM PAGE 0
return
;
; -------
; MESSAGE
; -------
;
message movlw '1'
call send
movlw '6'
call send
movlw 'F'
call send
movlw '8'
call send
movlw '7'
call send
movlw '7'
call send
movlw 'a'
call send
movlw ' '
call send
movlw 'w'
call send
movlw 'o'
call send
movlw 'r'
call send
movlw 'k'
call send
movlw 'i'
call send
movlw 'n'
call send
movlw 'g'
call send
movlw 0x0D ; CR
call send
movlw 0x0A ; LF
call send
return
END
I have question :
1) i'm using window 7, i have already download hyperterminal software and use it. It is a problem that window 7 did not support the hyperterminal software so that it can't display out.
2) Below code i have build it succesfully. It's there anything wrong with the code that cause it did not display.
LIST P=16F877A
PROCESSOR 16f877a
#include <P16F877A.INC> ; Include header file
__CONFIG _CP_OFF & _DEBUG_OFF & _CPD_OFF & _LVP_OFF & _BODEN_OFF & _PWRTE_ON & _WDT_OFF & _XT_OSC
CBLOCK 0x20 ; Declare variable addresses starting at 0x20
dataL
ENDC
org 0x0000
goto START
org 0x0010
START
bsf STATUS,RP0 ; RAM PAGE 1
movlw b'00000000' ; set up TRISC
movwf TRISC
;Boot Baud Rate = 9600, No Parity, 1 Stop Bit
;
movlw d'129' ; 0x19=9600 bps (0x0C=19200 bps)
movwf SPBRG
movlw b'00100100' ; brgh = high (2)
movwf TXSTA ; enable Async Transmission, set brgh
bcf STATUS,RP0 ; RAM PAGE 0
movlw b'10010000' ; enable Async Reception
movwf RCSTA
; PROVIDE A SETTLING TIME FOR START UP
; ------------------------------------
;
clrf dataL
settle decfsz dataL,F
goto settle
movf RCREG,W
movf RCREG,W
movf RCREG,W ; flush receive buffer
;
; ---------
; MAIN LOOP
; ---------
;
call message ; send "16F628 alive"
loop call receive ; wait for a char
call send ; send the char
goto loop
;
; -------------------------------------------
; RECEIVE CHARACTER FROM RS232 AND STORE IN W
; -------------------------------------------
; This routine does not return until a character is received.
;
receive
btfss PIR1,RCIF ; (5) check for received data
goto receive
movf RCREG,W ; save received data in W
return
;
; -------------------------------------------------------------
; SEND CHARACTER IN W VIA RS232 AND WAIT UNTIL FINISHED SENDING
; -------------------------------------------------------------
;
send movwf TXREG ; send data in W
TransWt
bsf STATUS,RP0 ; RAM PAGE 1
WtHere
btfss TXSTA,TRMT ; (1) transmission is complete if hi
goto WtHere
bcf STATUS,RP0 ; RAM PAGE 0
return
;
; -------
; MESSAGE
; -------
;
message movlw '1'
call send
movlw '6'
call send
movlw 'F'
call send
movlw '8'
call send
movlw '7'
call send
movlw '7'
call send
movlw 'a'
call send
movlw ' '
call send
movlw 'w'
call send
movlw 'o'
call send
movlw 'r'
call send
movlw 'k'
call send
movlw 'i'
call send
movlw 'n'
call send
movlw 'g'
call send
movlw 0x0D ; CR
call send
movlw 0x0A ; LF
call send
return
END