vishy71
Full Member level 2
Hi my friends.
I have an problem in my code!
I wanna send 'INIT' to PC and then read data from it but I can't!because of TXIF flag bit!
when I am config bits and registers suddnely TXIF =1 and my program jump in interrupt routin!
I clear TXIE but when i wanna send 'INIT' to pc I must check TXIF and it is 1 logic so 'N' dosn't send to pc!here is my code!but it is not complete because of my problem.
thanks
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
CALL INTERRUPT ;INTERRUPT ROUTIN
RETFIE
MAIN:
MOVLW 0XC0
MOVWF INTCON
MOVLW 0X98
MOVWF RCSTA
BSF STATUS,5 ;JUMP TO BANK1
CLRF TRSIA ;PORTA AS AN OUTPUT
CLRF TRSIB ;PORTB AS AN OUTPUT
BSF TRISB,1 ;RX PIN
MOVLW 0X20
MOVWF TXSTA
MOVLW 0X0C
MOVWF SPBRG
MOVLW 0X20
MOVWF PIE1
BCF STATUS,5
;SEND INIT TO PC
MOVLW 'I'
MOVWF TXREG
BTFSS PIR1,4
GOTO $-1
BCF PIR1,4
MOVLW 'N'
MOVLW 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
BTFSC PIR1,4
GOTO $-1
BCF PIR1,4
MOVLW 0X00
GOTO $-1
INTERRUPT:
RETURN
END
Can I send data in other way?Please help me.thanks
I have an problem in my code!
I wanna send 'INIT' to PC and then read data from it but I can't!because of TXIF flag bit!
when I am config bits and registers suddnely TXIF =1 and my program jump in interrupt routin!
I clear TXIE but when i wanna send 'INIT' to pc I must check TXIF and it is 1 logic so 'N' dosn't send to pc!here is my code!but it is not complete because of my problem.
thanks
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
CALL INTERRUPT ;INTERRUPT ROUTIN
RETFIE
MAIN:
MOVLW 0XC0
MOVWF INTCON
MOVLW 0X98
MOVWF RCSTA
BSF STATUS,5 ;JUMP TO BANK1
CLRF TRSIA ;PORTA AS AN OUTPUT
CLRF TRSIB ;PORTB AS AN OUTPUT
BSF TRISB,1 ;RX PIN
MOVLW 0X20
MOVWF TXSTA
MOVLW 0X0C
MOVWF SPBRG
MOVLW 0X20
MOVWF PIE1
BCF STATUS,5
;SEND INIT TO PC
MOVLW 'I'
MOVWF TXREG
BTFSS PIR1,4
GOTO $-1
BCF PIR1,4
MOVLW 'N'
MOVLW 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
BTFSC PIR1,4
GOTO $-1
BCF PIR1,4
MOVLW 0X00
GOTO $-1
INTERRUPT:
RETURN
END
Can I send data in other way?Please help me.thanks