8051 serial problems

Hi,

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 RS232RS485 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 trigger. 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.

Regards, Edo Reshef

Reply to
Edo Reshef
Loading thread data ...

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

Reply to
Tauno Voipio

No wonder computers never work!

I'm using 11.0592Mhz And that the Init code: MOV PCON,#80h MOV SCON,#0C8H ;SET SERIAL PORT TO MODE 3 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

Reply to
Edo Reshef

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

Reply to
Dingo

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!

Reply to
Edo Reshef

Hi,

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.

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

Reply to
Edwin Bland

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!

Reply to
Edo Reshef

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.