pic 433mhz
Hello,
I’m using the PIC 16F870 USART TX/RX for sending data over RF link at 433MHz.
The USART, works fine with baud rate of 4,800b/s (OSC=4MHz).
When I’m adding the RF link so the TX USART sends that data into the RF transmitter, and the data out of the RF receiver
Is feeding into the RX USART of the receiver PIC, most of the data that is received is corrupted, about 1/10 I get the right data.
I would like to know if anyone know how to operate this RF link using the USART, in a more robust way, so each byte that is transmitted
is also received properly. The USART TX and RX code is shown below.
Thanks in advanced,
Gideon.
TX_D
MOVLW 0x01 ; LOW byte TX
BTFSS PIR1,TXIF ; XMIT BUFFER EMPTY?
GOTO $-1 ; NO, WAIT
MOVWF TXREG ; YES, send data
CALL DELAY ; delay of 1ms
MOVLW 0x02 ; HIGH byte
BTFSS PIR1,TXIF ; XMIT BUFFER EMPTY?
GOTO $-1 ; NO, WAIT
MOVWF TXREG ; YES, send data
CALL DELAY_MS ; delay of 100ms
RX_D
; read the first byte
BTFSS PIR1,RCIF ; judge if RX buffer is full
GOTO $-1 ; if not, continue to check
MOVF RCREG,W ; if yes, move the receive data to W
MOVWF DATL ; save the first byte in DATL register
BCF RCSTA,CREN ; Clear receive enable bit, for resetting
BSF RCSTA,CREN ; Set receive enable bit
; read the second byte
BTFSS PIR1,RCIF ; judge if RX buffer is full
GOTO $-1 ; if not, continue to check
MOVF RCREG,W ; if yes, move the received data to W
MOVWF DATH ; save the second byte in DATH register
RETURN