Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

at89c51 sending junk through serial port

Status
Not open for further replies.

baftab

New Member
hi..am trying to send data through serial port of at89c51 to my pc
i send "re364 acknwlge" and the pc receives re364 acknwlge with some junk as subscript
i hav to turn on and off my controller several times before it sends the correct one



üre364 acknwlgere364 acknwlgere364 acknwlgere364 acknwlgeàre364 acknw
lgeðre364 acknwlgeàre364 acknwlge ü

the ones in bold are the garbage values send! help! how to overcome this problem
 
Write the correct code maybe
or use the correct hardware
maybe also be sure about the baud rate
or ... ...

With some code and hardware it would be easier to help you :)
 
here is the code

org 000h

mov r1,#30h ;bytes for ack
mov r3,#8 ;counter for ack
mov r0,#28h ;bytes for id tag
mov r4,#32 ;counter for id tag
mov r2,#10

mov p1,#00110011b
mov p2,#00110011b
mov p0,#00110011b

mov A,pcon
setb acc.7
mov pcon,A
mov tmod,#20h
mov th1,#-3
mov scon,#50h

setb tr1

again:mov DPTR,#rfid

h_1: clr A
movc A,@A+dptr
jz b_1
acall send
inc dptr
sjmp h_1

b_1: acall recv
mov p0,@r1
inc r1
djnz r3,b_1
sjmp verify

send:mov sbuf,A
h_2:jnb ti, h_2
clr ti
ret

recv: jnb ri,recv
mov A,sbuf
mov @r1, A
clr ri
ret

verify:

mov r1,#30h
mov p2,@r1
cjne @r1,#'a',bil
sjmp tag_id
bil:sjmp again ;if ack not recieved, send again

tag_id: mov r2,#10
mov r0,#28h ;to keep bytes from 28 to 32
loop:acall recv1
mov p0,@r0
inc r0
djnz r2,loop
djnz r4,tag_id
sjmp verify2

recv1: jnb ri,recv1
mov A,sbuf
mov @r0,A
clr ri
ret


verify2:
mov r0,#28h
cjne @r0,#'3',bil1
mov p1,#11100010b
;set a flag bit,assign space;check sensors
sjmp again
bil1: mov p1,#10010011b

org 0300h
rfid: DB "re364 acknwlge",0
end
 
i am interfacing with a RFID reader...which works on 19200bps
so my baudrate is 19200

to check whether its transmitting correctly, i connected my at89c51 with hyper terminal
but found out tht its sending trash as the frst byte

using 11.0592M oscillator
 
Your initilisation lacks
Code:
	setb TI	;TI:   set TI to send first char of UART
Didn't check the rest of the code :)
 
I found that noise plays havoc on the 8051 and wireless. My circuit didn't work very reliably until I lowered the clock frequency.

I lowered the clock frequency from 11.0592 MHz to 4MHz, it made the world of difference in receiving errors. (providing your hardware, code and uart config is set up correctly)
 
Status
Not open for further replies.

Latest threads

Back
Top