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.

Serial communication problems

Status
Not open for further replies.

labrat31

New Member
Having problems communicating between my 8051 and labview/HyperTerminal. I seem to get the wrong information received to both pc and 8051. I know the path is ok because I use it to flash using isp
When I receive from pc I get random data received and displayed on a port but not so random that the data sent will display differently on the port each time. . . like the same data sent will display the same random data each time. But the data I do receive seems to be a little glitchy, on receive it will flash a number of leds for a split second and keep others fully lit up. I get a number of dull, fully lit and off led’s when I repeat the communication with small delay.
Im just using the serial VISA example or Hyper Terminal set up like this:
Com 1 (no risopnce at all form com 2)
Baurd rate. 4800 (have tried others)
Bits. 8
Parity. None
Stop. 1
Flow. None
Delay R/W. 500ms (on labview only)
is my code

Write a program for the 8051 to receive bytes of data serially, and
put them in P1, set the baud rate at 4800, 8-bit data, and 1 stop bit
Solution:

MOV TMOD,#20H ;timer 1,mode 2(auto reload)
MOV TH1,#-6 ;4800 baud rate
MOV SCON,#50H ;8-bit, 1 stop, REN enabled
SETB TR1 ;start timer 1
HERE: JNB RI,HERE ;wait for char to come in
MOV A,SBUF ;saving incoming byte in A
MOV P1,A ;send to port 1
CLR RI ;get ready to receive next byte
SJMP HERE ;keep getting data

can anyone help?? Thank you
 
One question! Where did you get your board? Was it home made, or was it from a kit?

I had the exact same problem with a board made for me years ago (I don't use it any more) but I had to ground out ALL the unused pins on the RS232 chip (it was bouncing all over the place)

Might / might not be the case, but mine uploaded programs perfectly as well

Ian
 
Got it working on another port at x2 pc board rerate for now. will have to fix code up later with PCON.7 cleared, my other problem was a faulty p0.3 and did not invert data to go to port to mach hard wear. Which made it a little hard to get my head around fault finding, as I am only new to this
But im happy now I know what im doing with serial
Thank you
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top