hi everyone ..
I am striving to make a simple example of uart .. my circuit diagram is
the switch at Tx, when pushed, is to cause Tx to send the character 0xAB to Rx, which will ,in turn, indicate the receiption of this character on the corresponding leds .. my code (of course) doesn't work at all ..
Tx code:
Rx code:
I am striving to make a simple example of uart .. my circuit diagram is
the switch at Tx, when pushed, is to cause Tx to send the character 0xAB to Rx, which will ,in turn, indicate the receiption of this character on the corresponding leds .. my code (of course) doesn't work at all ..
Tx code:
Rich (BB code):
processor 16f877a
include <p16f877a.inc>
__config _HS_OSC & _WDT_OFF & _PWRTE_ON
;configuring TX of UART
banksel TRISA
movlw 0xFF
movwf TRISA
bsf TXSTA, BRGH ;high speed
banksel SPBRG
movlw 0x19
movwf SPBRG ;set baud rate to 9600
banksel RCSTA
bsf RCSTA, SPEN
banksel TXSTA
bsf TXSTA, TXEN
bcf TXSTA, SYNC
rep
banksel PORTA
btfsc PORTA,0
goto transmit
btfss PORTA,0
goto rep
transmit
movlw 0xAB
banksel TXREG
movwf TXREG
goto rep
end
Rx code:
Rich (BB code):
processor 16f877a
include <p16f877a.inc>
__config _HS_OSC & _WDT_OFF & _PWRTE_ON
;configuring RX of UART
banksel TRISA
movlw 0x00
movwf TRISA
banksel RCSTA
bsf RCSTA, SPEN
banksel TXSTA
bcf TXSTA, SYNC
bsf TXSTA, CREN
bsf TXSTA, BRGH ;high speed
banksel SPBRG
movlw 0x19
movwf SPBRG ;set baud rate to 9600
k
banksel PIE1
btfsc PIE1, RCIF
goto m
nop
m
banksel RCREG
movf RCREG,w
banksel PORTA
movwf PORTA
goto k
end