list p=16f648a
#include
__CONFIG _BODEN_OFF & _CP_OFF & _MCLRE_OFF & _WDT_OFF & _PWRTE_ON & _LVP_OFF & _INTOSC_OSC_NOCLKOUT
ORG 0x000
goto main
ORG 0x004
retfie
main
bsf STATUS,RP0
movlw 0xff
movwf TRISA
movlw 0xfb
movwf TRISB
bcf STATUS,RP0
movlw 07H
movwf CMCON
bsf STATUS,RP0
movlw 0x19 ; set bps
movwf SPBRG
movlw B'00100100'
movwf TXSTA
bcf STATUS,RP0
movlw B'10010000'
movwf RCSTA
mainloop
btfss PIR1, 5
goto mainloop
movf RCREG, W ; data in
bsf STATUS,RP0
loop1
btfss TXSTA, 1
goto loop1
bcf STATUS,RP0
movwf TXREG ; data out
goto mainloop
|