kemalkemal
Member level 1
Hi all,
I am using PIC18f24K22, mpasm, real term and a 3rd party development board.
My problem is; i can send data via uart-tx but i couldn't receive it from the opponent side. My code is just an infinite loop (for debug) that is sending some binary data continously. Interesting thing is i can see my transmitted signal on the oscilloscope screen but i couldn't get it from the realterm window. Accidentally I found a solution to this. First i start the code, start to send data and see it on the oscilloscpe.Then in the opposite direction, i just send a dummy data from realterm to pic (which is still running and doesn't have any receive code).Bingo. the data starts to flow on realterm window.
I suspected if realterm configuration is faulty. Instead of realterm i tried to send some configuration data to microchips data logger app which communicates to pic via usart module. App didn't receive conf data. But then i tried the same thing; first send a dummy data via the app app to pic (again although there isn't any receive code in the pic). Only after this, app began to receive.
So i came to this ; in order to send data with pic first i should receive sthg. But unfortunately at my real project i couldn't control the opponent side.
Is there anything you can suggest?
MY MAIN CODE===>
MY USART CONF CODE===>
I am using PIC18f24K22, mpasm, real term and a 3rd party development board.
My problem is; i can send data via uart-tx but i couldn't receive it from the opponent side. My code is just an infinite loop (for debug) that is sending some binary data continously. Interesting thing is i can see my transmitted signal on the oscilloscope screen but i couldn't get it from the realterm window. Accidentally I found a solution to this. First i start the code, start to send data and see it on the oscilloscpe.Then in the opposite direction, i just send a dummy data from realterm to pic (which is still running and doesn't have any receive code).Bingo. the data starts to flow on realterm window.
I suspected if realterm configuration is faulty. Instead of realterm i tried to send some configuration data to microchips data logger app which communicates to pic via usart module. App didn't receive conf data. But then i tried the same thing; first send a dummy data via the app app to pic (again although there isn't any receive code in the pic). Only after this, app began to receive.
So i came to this ; in order to send data with pic first i should receive sthg. But unfortunately at my real project i couldn't control the opponent side.
Is there anything you can suggest?
MY MAIN CODE===>
Code:
LIST P=18F24K22, F=INHX32 ;directive to define processor and file format
INCLUDE <P18F24K22.INC> ;processor specific variable definitions
UDATA_ACS
data_h1 RES 1
EXTERN P18_usart,P18_usart1_conf,P18_usart1_send
GLOBAL data_h1
RESET_VECTOR CODE 0x0000
goto Main
CODE
Main:
CALL P18_usart1_conf
DELAY_1MS
START1
MOVLW 0xFF
MOVWF data_h1
CALL P18_usart1_send
BRA START1
END
Code:
LIST p=18f24K22
#INCLUDE <p18f24K22.inc>
GLOBAL P18_usart,P18_usart1_conf
GLOBAL P18_usart1_send
EXTERN data_h1
CODE
P18_usart
P18_usart1_conf:
MOVLW B'00100100'
MOVWF TXSTA1
MOVLW B'10010000'
MOVWF RCSTA1
MOVLW .129 ;fosc=20 MHz ---> baud rate 9.6k
MOVWF SPBRG1;
BSF TRISC,TX ;C6
BSF TRISC,RX ;C7
RETURN;
P18_usart1_send:
START_SEND1
MOVF data_h1,W
S1
BTFSS PIR1,TX1IF ;Kodun bu parçasi BOOK PIC18f kitabindan alinmadir
BRA S1
MOVWF TXREG1
RETURN