processor p16f628a
include <p16f628a.inc>
__config _HS_OSC & _WDT_OFF & _PWRTE_OFF & _BOREN_OFF & _BODEN_OFF & _CP_OFF
ORG 0X00
GOTO MAIN ;MAIN CODE
ORG 0X04
GOTO INTERRUPT ;INTERRUPT ROUTINE
MAIN:
MOVLW 0XC0
MOVWF INTCON
MOVLW 0X98
MOVWF RCSTA
BSF STATUS,5 ;JUMP TO BANK1
;BANKSEL TRISA
CLRF PORTA
CLRF PORTB
CLRF TRISA ;PORTA AS AN OUTPUT
CLRF TRISB ;PORTB AS AN OUTPUT
BSF TRISB,1 ;RX PIN
BSF TRISB,2 ;TX PIN - according to datasheet
MOVLW 0X20
MOVWF TXSTA
MOVLW 0X0C
MOVWF SPBRG
MOVLW 0X0
MOVWF PIE1
BCF STATUS,5
;SEND INIT TO PC
;BANKSEL TXREG
MOVLW 'I'
MOVWF TXREG
BTFSS PIR1,4
GOTO $-1
BCF PIR1,4
MOVLW 'N'
MOVWF TXREG
BTFSS PIR1,4
GOTO $-1
BCF PIR1,4
MOVLW 'I'
MOVWF TXREG
BTFSS PIR1,4
GOTO $-1
BCF PIR1,4
MOVLW 'T'
MOVWF TXREG
BTFSS PIR1,4
GOTO $-1
BCF PIR1,4
MOVLW 0X00
GOTO $-1
INTERRUPT:
RETFIE
END
MOVLW 'N'
MOVLW TXREG ; Should be MOVWF TXREG, I fixed it in the code
BTFSS PIR1,4
GOTO $-1
__config _HS_OSC & _WDT_OFF & _PWRTE_OFF & _BOREN_OFF & _BODEN_OFF _CP_OFF
ORG 0X04
CALL INTERRUPT ;INTERRUPT ROUTIN
RETFIE
INTERRUPT:
RETURN
ORG 0X04
GOTO INTERRUPT ;INTERRUPT ROUTINE
INTERRUPT:
RETFIE
rx_rs232 btfss PIR1, RCIF ;check for received data
goto rx_rs232
movf RCREG,W
return
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?