be_sincere86 said:I m having problem in interfacing RF transmitter tsw and receiver rsw 434 with microcontroller 8051.
be_sincere86 said:is it necessary to connect encoder decoder between controller and tsw/rsw-434 ?
which serial mode should i use ?
be_sincere86 said:plz help me and guide me how to make this simple communication project
be_sincere86 said:im using assembly
and 89c51 both sides trns and receiver.
be_sincere86 said:plz if u have some idea about it plz do share it with me
"The protocol you use must filter out the packets, and it is a good idea to use some kind of CRC in the packet. I used a 4 byte packet with 8 bit CRC. "
;*********************************************
;UART Test code
$mod51
;this one uses UART hardware to TX @2400 Baud
;timing is adapted for 11.0592 MHz crystal
;****************************************************
org 00000h
Reset:
sjmp Start ;reset vector
Start:
MOV SP,#70h ; Start stack near top of '51 RAM.
mov a,#0FFh ; clear Ports
mov p1,a ;
mov p3,a ;
;------Initialize Uart------------
MOV SCON,#01010000B ;(50H) Mode 1/Rec en
; bit 4 = REN receive enable
; bit 6 = mode 1. - 8 bit uart variable baud rate
;; MOV TH1,#0E8H ; Reload value for 1200 Bd @11.0592 MHz
MOV TH1,#0F4H ; Reload value for 2400 Bd @11.0592 MHz
;; MOV TH1,#0FAH ; Reload value for 4800 Bd @11.0592 MHz
MOV TMOD,#00100000B ; (21H) Gate1/Timer/Mode 2 / Gate0/Timer/Mode 1
; bit 5 = 8 bit auto reload for timer 1 (Mode2)
setb TR1 ; start timer 1
;----------------------------------------------
Main:
clr a
Main1:
lcall transmit
inc acc
acall Time1mS
sjmp Main1
;----------------------------------------------
Time1mS:
MOV R2,#2
MOV R1,#221
tim1mS:
DJNZ R1,$
DJNZ R2,tim1mS
RET
;----------------------------------------------
transmit:
MOV SBUF,A
JNB TI,$
CLR TI
ret
;----------------------------------------------
end
;*********************************************
;UART Test receiver code
$mod51
;this one uses hardware uart to receive @2400 Baud
;timing is adapted for 11.0592 MHz clock
;
;port 3 pinouts
;----------------------------------------------------
org 00000h
Reset:
sjmp Start ; reset vector
Start:
MOV SP,#070h ; Set up stack pointer
mov a,#0FFh ; clear Ports
mov p1,a ;
mov p3,a ;
;------Initialize Uart------------
MOV SCON,#01010000B ;(50H) Mode 1/Rec en
; bit 4 = REN receive enable
; bit 6 = mode 1. - 8 bit uart variable baud rate
;; MOV TH1,#0E8H ; Reload value for 1200 Bd @11.0592 MHz
MOV TH1,#0F4H ; Reload value for 2400 Bd @11.0592 MHz
;; MOV TH1,#0FAH ; Reload value for 4800 Bd @11.0592 MHz
MOV TMOD,#00100000B ; (21H) Gate1/Timer/Mode 2 / Gate0/Timer/Mode 1
; bit 5 = 8 bit auto reload for timer 1 (Mode2)
setb TR1 ; start timer 1
;----------------------------------------------
Main:
lcall receive ;receive data from terminal
lcall transmit ;echo it back to terminal
sjmp Main
;----------------------------------------------
; Receive a character and return in ACC
receive:
JNB RI,$ ;wait here for receive int
MOV A,SBUF ;get data
CLR RI ;clear receive int
ret
;----------------------------------------------
;Transmit a character from ACC
transmit:
MOV SBUF,A
JNB TI,$
CLR TI
ret
;----------------------------------------------
end
Main1:
lcall receive ;receive data from uart
cjne a,#099h,Main1 ;compare received byte with 99h
;if its different, restart
mov 08h,a ;save first byte received
;we are here because first received byte compares to 0x99
lcall receive ;get second byte
;-------------
cjne a,#088h,Main1 ;compare received byte with 88h
mov 09h,a ;save second byte received
;next the program gets two more bytes (total 4 bytes)
;then xor first three bytes together
;then compare last byte with xor value of 3 first bytes
;not the same? go back to Main1
;this way you are SURE that your receiving code won't pick up garbage bytes.
;I mean it always will, but you must ignore the garbage.
be_sincere86 said:error accurs while burning the hex file. EZ3 writes the code perfactly but while verifying it, it generate an error.
somtimes it doesnt appear, and process completes successfully.
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?