16f628a txreg

Status
Not open for further replies.

Avalan

New Member
Hi,

I am working on a project that interface a compass module with my PC. First of I just developed a status checking routine just to make sure the serial port connection is fine. Sending '1' to the PIC should make it reply with the character 'O'.

After writing my code and sending '1' to the PIC I only sometimes get the 'O' character the rest of the time I get '╧'.

I compared their binary values and found: O = 0100 1111 and ╧ = 1100 1111 so it seems that somewhere along the line a 1 is added to the MSB. I can also not find any pattern, sometimes its 'O' and sometimes its '╧'. I cant understand how this is possible as my code is very simple:

;Write 'O' to serial port
;-------------------------------------------------------------------------
SerialOutOK:
MOVLW 'O' ;Load character 'O'
MOVWF W_Data
CALL SerialOut ;Send character through serial port
;-------------------------------------------------------------------------

;SerialOut
;-------------------------------------------------------------------------
SerialOut:
;Select bank0
BCF STATUS,RP0
BCF STATUS,RP1

BTFSS PIR1,4 ;Wait for the previous byte to finnish
GOTO $-1

MOVF W_Data,W ;Load new byte
MOVWF TXREG

RETURN
;-------------------------------------------------------------------------


I am missing something somewhere, maybe some kind of masking?
My output is viewed on hyperterminal.

Hope somebody can see something I am missing, thanks in advance!
 
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…