8051 serial problems

Do you have a question? Post it now! No Registration Necessary

Translate This Thread From English to

Threaded View

I have an 8051 controller that communicates over RS485 to other 8051
controller. The communication is half-duplex at baud of 57600, and it
works great. So far so good.
Lately, I'm trying to make the 8051 device talk with a PC, since it is
57600 and I have RS232<>RS485 converter this should be simple.

I'm encountering strange problems at the 8051 reception, I never
received what I send from the PC. For example:
             msb  lsb
PC Sends  -> 11011011
8051 Gets -> 10111011

PC Sends  -> 10110011
8051 Gets -> 01110011

PC Sends  -> 11000101
8051 Gets -> 10000101

PC Sends  -> 10101011
8051 Gets -> 01001011

Even more, when the msb is "0" the reception interrupt does not
It looks like the 8051 ignores the PC start bit or something...

The protocol is 9-bit multi-drop, which i already implemented on PC
side using Space and Mark parities, it worked fine with some other
9-bit PIC devices.

I'm debugging the 8051 device with a DS-ICE but i don't think this is
the problem.
I'm totally out of ideas what could be wrong.

  Edo Reshef

Re: 8051 serial problems
Quoted text here. Click to load it

This has a strong scent of a speed / distorsion error. It seems that
after 6 bits, the 8051 is off by one bit time.

Please remember that initially the RS-232 standard limited the transfer
speed to 20000 bits/s. There may be edge slow-down capacitors at either
or both ends of the RS-232 data lines.

Which crystal and what divisor are you using on the 8051's?

Tauno Voipio
tauno voipio @ iki fi

Re: 8051 serial problems
Quoted text here. Click to load it

No wonder computers never work!

Quoted text here. Click to load it

I'm using 11.0592Mhz
And that the Init code:
  MOV     PCON,#80h
  MOV     TCON,#01H
  MOV     TMOD,#21H       ;SET TIMER 0 TO MODE 1 - 16 BIT MODE
                          ;AND TIMER 1 TO MODE 2 - AUTO RELOAD MODE
  MOV     TH1,#0FFH       ;SET TIMER 1 TO PRODUCE 57600 BAUD (0FFH) ?
  SETB    TR1             ;START TIMER 1

Re: 8051 serial problems
snipped-for-privacy@hotmail.com (Edo Reshef) wrote in message
Quoted text here. Click to load it

Are you sure your emulator isn't using an on-board 10Mhz crystal?

Re: 8051 serial problems
Quoted text here. Click to load it

That's actually my main suspicion, I think the Ceibo DS-51 could have
an Internal clock that runs at 12Mhz, DS-51 documentation says nothing
about it. Anyway I will to physically look for crystal in the emulator
in few dayz since it's weekend here... I'll keep you updated!

Re: 8051 serial problems

My Ceibo emulator came with a default 24.0 Mhz crystal.  It has divider
jumpers... with the default being at 12.0 Mhz.  I had to get another the
crystal to get nonmultiple frequencies.


Quoted text here. Click to load it

Re: 8051 serial problems
Problem Solved!
Ceibo manual doesn't say anything about it, but you can choose
External OR Internal clocking inside the device. Thanks to everyone
here I opened the emulator and found a crystal! I changed it and it
works perfect.
I changed 12.0mhz crystal with 11.0592mhz - exactly 10% difference!
Nice one!
I'm actually quite impressed from the skills people showed around, I
guess I have lots to learn.

Really thanks guys, you helped a lot!

Quoted text here. Click to load it

Site Timeline