Hello people, nice to find you.
I have a problem receiving some characters typed in windows hyperterminal.
my code (I excluded CBLOCK and CONFIG) is:
As you can see I am sending the word 'UP', that works fine.
The problem is with receiving the word 'OK'... I type 'OK' in hyperterminal but nothing happens. When I type another character it seems like I am having an overflow or something (i guess the 3 character program breaking has to do something with the RCREG size).
I tried to spot where the program breaks by placing the debug code you can see above. So now when I write a third character in hyperterminal I get an endless 'P' output in my terminal.
I use an RC oscillator at 4mhz but I don't think that is the problem.
Thank you in advance for your help.
I have a problem receiving some characters typed in windows hyperterminal.
my code (I excluded CBLOCK and CONFIG) is:
Rich (BB code):
BSF STATUS,5
MOVLW 0X07
MOVWF CMCON ;DISABLE ANALOG COMPARATORS
MOVLW 0X06
MOVWF ADCON1 ;PORTA DIGITAL PINS
MOVLW 0X00
MOVWF TRISA
MOVLW 0X00
MOVWF TRISB
MOVLW B'10000000'
MOVWF TRISC
MOVLW 0X19
MOVWF SPBRG ;BAUD RATE 9600
MOVLW B'00100100'
MOVWF TXSTA
BCF STATUS,5
MOVLW B'10010000'
MOVWF RCSTA
CLRF PORTA
CLRF PORTB
CLRF PORTC
CLRW
MOVF RCREG,W
MOVF RCREG,W ;CLEAR RECEIVE BUFFER
MOVF RCREG,W
MOVLW 'U'
CALL SEND
MOVLW 'P'
CALL SEND
MOVLW 0X0D
CALL SEND
MOVLW 0X0A
CALL SEND
CALL RECEIVE
MOVLW 'P' ;DEBUG ONLY
CALL SEND ;DEBUG ONLY
MOVLW 0X0D ;DEBUG ONLY
CALL SEND ;DEBUG ONLY
MOVLW 0X0A ;DEBUG ONLY
CALL SEND ;DEBUG ONLY
SUBLW 'O'
BTFSS STATUS,Z
GOTO $-9
CALL RECEIVE
SUBLW 'K'
BTFSS STATUS,Z
GOTO $-3
BSF PORTB,7
.
.
.
.
RECEIVE
BTFSC PIR1,RCIF
GOTO $+15
MOVLW D'100' ;DELAY CODE
MOVWF d1
MOVLW D'200'
MOVWF d2
NOP
NOP
DECFSZ d2,1
GOTO $-3
DECFSZ d1,1
GOTO $-7
MOVLW 0X00
MOVWF PORTA
BCF PORTB,6
GOTO RECEIVE
BCF PORTB,5 ;DEBUG ONLY YLW
MOVF RCREG,W ;FETCH CODE
RETURN
SEND
MOVWF TXREG
BSF STATUS,5
BTFSS TXSTA, TRMT
GOTO $-1
BCF STATUS,5
RETURN
The problem is with receiving the word 'OK'... I type 'OK' in hyperterminal but nothing happens. When I type another character it seems like I am having an overflow or something (i guess the 3 character program breaking has to do something with the RCREG size).
I tried to spot where the program breaks by placing the debug code you can see above. So now when I write a third character in hyperterminal I get an endless 'P' output in my terminal.
I use an RC oscillator at 4mhz but I don't think that is the problem.
Thank you in advance for your help.