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===>
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
MY USART CONF CODE===>
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
This is strange. I can't see anything wrong in the code. Are you sure you are connecting the interface correctly, with level converters as necessary?
If that isn't the problem, try reading the USART receive register twice after the initialization, it will clear any errors and pending interrupts.
Thanks Brian, level converter idea solved my problem. I changed USB-serial port converter. But it is interesting what i found out.
This is the brown converter that i used in the unsuccessful trials.(I paid lots of money to this)
**broken link removed**
This is the negative signal level when i connect brown converter to dev.board (board is not energised).
This is the normal signal level when i start the board and run the code. I cant receive the data unless i kick the pic with a dummy data.
And now the working one is coming (the cheaper also
This is the 0 volts signal level when i connect green converter to dev.board (board is not energised).
This is the normal signal level when i start the board and run the code. I receive data immediately after power up.
As you can see the only difference is the signal level at the beginning even the board is not energised.