kemalkemal
Member level 1
Hi all,
I have wrote a small program for usart module at mplabx ide v2.35. I am using Realterm for communication software. Between my development board and usb port of pc there is a USB-serial converter. My problem is: when i send 0x82, i receive 0x22 most of the time. Interesting thing is that; whenever I control my data from the output pin of max232 (just before the USB-serial converter) with an oscilloscope everything seems ok. So i am suspicious on converter thing or Realterm. Here is my code. Any problem can you see?
and this is the screen shot.
I have wrote a small program for usart module at mplabx ide v2.35. I am using Realterm for communication software. Between my development board and usb port of pc there is a USB-serial converter. My problem is: when i send 0x82, i receive 0x22 most of the time. Interesting thing is that; whenever I control my data from the output pin of max232 (just before the USB-serial converter) with an oscilloscope everything seems ok. So i am suspicious on converter thing or Realterm. Here is my code. Any problem can you see?
Code:
LIST P=18f4520
INCLUDE <p18f4520.inc>
RES_VECT CODE 0x0000
GOTO START
INT_VECT CODE 0x0008
GOTO START
#DEFINE CLK_20MHZ
EXTERN P18_usart
GLOBAL FLAG,SEND_DATA
UDATA_ACS
FLAG RES 1 ;PIC18_usart.asm
SEND_DATA RES 1 ;PIC18_usart.asm
MAIN_PROG CODE
START
SEND_START
CLRF SEND_DATA
MOVLW 0x82
MOVWF SEND_DATA
CALL P18_usart
BRA SEND_START
END
Code:
LIST p=18f4520
#INCLUDE <p18f4520.inc>
#DEFINE USART_FLAG FLAG,1
GLOBAL P18_usart
EXTERN FLAG,SEND_DATA
CODE
P18_usart
BTFSC USART_FLAG,0
GOTO START_SEND ;USART_FLAG,0=1 ise
#IFDEF CLK_20MHZ ;Tcy=200ns
BSF TXSTA,BRGH ;BRGH=1 , high speed asynch
MOVLW .129 ;fosc=20 MHz ---> baud rate 9.6k
MOVWF SPBRG;
#ENDIF
BCF TRISC,TX
BSF RCSTA,SPEN ;Serial Port enabled.(configures RC7/RX/DT and RC6/TX/CK pins as serial port pins)
BSF TXSTA,TXEN
BSF USART_FLAG,0
START_SEND
BTFSS PIR1,TXIF
BRA START_SEND
MOVFF SEND_DATA,TXREG
RETURN
END
and this is the screen shot.