6502.org Forum  Projects  Code  Documents  Tools  Forum
It is currently Sat Sep 21, 2024 5:21 am

All times are UTC




Post new topic Reply to topic  [ 49 posts ]  Go to page 1, 2, 3, 4  Next
Author Message
 Post subject: RS232... here goes!
PostPosted: Thu Apr 16, 2015 2:06 pm 
Offline
User avatar

Joined: Sun Sep 08, 2013 10:24 am
Posts: 740
Location: A missile silo somewhere under southern England
Yeah, so I'm finally tackling my nemesis: Well, one of them at least! RS232C.

I've already got a serial card installed in my PC, have got some WDC W65C02N ICs and a MAX232 or two.

Hooking up. Here's my circuit digram. I've made it by examining circuit diagrams that I've found elsewhere.
Can someone cast a beady eye of it to ensure that I've gotten it right?

I'm havaing a good e-read through Garth's guide and the W65C51N datasheet to see how it actually works. I get the whole -10 to -12V as a 1 and +10 to +12V as a 0, the bit sequence, and parity so far. Or at least I think I do :mrgreen:.

Attachment:
RS232C.png
RS232C.png [ 90.29 KiB | Viewed 1811 times ]


Top
 Profile  
Reply with quote  
 Post subject: Re: RS232... here goes!
PostPosted: Thu Apr 16, 2015 2:42 pm 
Offline
User avatar

Joined: Sun Sep 08, 2013 10:24 am
Posts: 740
Location: A missile silo somewhere under southern England
I might replace the 1.8432MHz crystal with an oscillator can of the same speed.

[edit] I wonder if, over longer distances, that a ferrite ring would help at all? Or what about splitting ground to 2 wires and twisting them together - much like Ethernet?


Top
 Profile  
Reply with quote  
 Post subject: Re: RS232... here goes!
PostPosted: Thu Apr 16, 2015 3:55 pm 
Offline
User avatar

Joined: Tue Mar 05, 2013 4:31 am
Posts: 1382
I've been running a serial port as a console on my 65C02 system for a couple years now. I implemented a full RS232 port using a Maxim 238. Some things to think about:

1- Use RTS/CTS handshaking (hardware handshake, aka 5-wire null modem) to ensure you can send and receive without losing data.
2- Use a double rate can oscillator and you'll get 38.4K baud rate (been running this way for a long time).
3- Consider a Serial/USB adapter instead of the Maxim level converters if you ultimately will be interfacing via a USB based serial port (like the FTDI stuff).
4- Careful on selecting a 65C51 chip and search the forums for the defective W65C51 issue with all new WDC sourced chips.

_________________
Regards, KM
https://github.com/floobydust


Top
 Profile  
Reply with quote  
 Post subject: Re: RS232... here goes!
PostPosted: Thu Apr 16, 2015 4:56 pm 
Offline
User avatar

Joined: Sun Sep 08, 2013 10:24 am
Posts: 740
Location: A missile silo somewhere under southern England
floobydust wrote:
I've been running a serial port as a console on my 65C02 system for a couple years now. I implemented a full RS232 port using a Maxim 238. Some things to think about:

1- Use RTS/CTS handshaking (hardware handshake, aka 5-wire null modem) to ensure you can send and receive without losing data.
2- Use a double rate can oscillator and you'll get 38.4K baud rate (been running this way for a long time).
3- Consider a Serial/USB adapter instead of the Maxim level converters if you ultimately will be interfacing via a USB based serial port (like the FTDI stuff).
4- Careful on selecting a 65C51 chip and search the forums for the defective W65C51 issue with all new WDC sourced chips.


Hi floobydust

I selected the W65C51 mainly due to knowing zilch about this kind of thing and because the WDC part runs at up to 14MHz. Can you give me an idea of what parts you use and how you set them up? I'd rather avoid using the W65C51 due to its xmit glitch... I just don't know enough to even get on the first rung with regard to non-65C51 parts.


Top
 Profile  
Reply with quote  
 Post subject: Re: RS232... here goes!
PostPosted: Thu Apr 16, 2015 6:05 pm 
Offline
User avatar

Joined: Thu May 28, 2009 9:46 pm
Posts: 8390
Location: Midwestern USA
banedon wrote:
I might replace the 1.8432MHz crystal with an oscillator can of the same speed.

Highly recommended.

Quote:
[edit] I wonder if, over longer distances, that a ferrite ring would help at all? Or what about splitting ground to 2 wires and twisting them together - much like Ethernet?

None of those steps are beneficial in my opinion. Ethernet is balanced to ground, whereas TIA-232 (aka RS-232) is not.

_________________
x86?  We ain't got no x86.  We don't NEED no stinking x86!


Top
 Profile  
Reply with quote  
 Post subject: Re: RS232... here goes!
PostPosted: Thu Apr 16, 2015 7:06 pm 
Offline
User avatar

Joined: Sun Sep 08, 2013 10:24 am
Posts: 740
Location: A missile silo somewhere under southern England
Ok the 16550 looks interesting (and is mentioned by Garth's tutorial):
http://uk.farnell.com/texas-instruments ... dp/9490507
Anyonr had any issues interfacing this with the 6502?

Looking at the data sheet it has (oddly, but not in a bad way) two read and two write lines: RD & /RD, WR & /WR.
From what I can tell, coupling one of these up is fine and then tying the other high or low (depending on the pin) to ensure that it's never active will work. A tad expensive at £10.03+VAT though.


Last edited by banedon on Thu Apr 16, 2015 7:10 pm, edited 2 times in total.

Top
 Profile  
Reply with quote  
 Post subject: Re: RS232... here goes!
PostPosted: Thu Apr 16, 2015 7:08 pm 
Offline
User avatar

Joined: Sun Sep 08, 2013 10:24 am
Posts: 740
Location: A missile silo somewhere under southern England
BigDumbDinosaur wrote:
banedon wrote:
I might replace the 1.8432MHz crystal with an oscillator can of the same speed.

Highly recommended.

Quote:
[edit] I wonder if, over longer distances, that a ferrite ring would help at all? Or what about splitting ground to 2 wires and twisting them together - much like Ethernet?

None of those steps are beneficial in my opinion. Ethernet is balanced to ground, whereas TIA-232 (aka RS-232) is not.

Ahh ok. Thanks BigD. I don't plan to take the line very far so this was just an inner-outer monolgue thinking aloud moment. :)


Top
 Profile  
Reply with quote  
 Post subject: Re: RS232... here goes!
PostPosted: Thu Apr 16, 2015 7:10 pm 
Offline
User avatar

Joined: Sun Oct 13, 2013 2:58 pm
Posts: 491
Location: Switzerland
Hi banedon,

With the 6551 I always use crystals and have not had any issues. Just carefully read the datasheet, some 6551 require a 1MOhm between XTI and XTO others don't. I prefer this solution as I can use the space under the 6551 for the crystal and the capacitors to save real estate on my PCB.

Normal baud-rates with a 1.8432MHz crystal indeed go only up to 19200. However there is the "external clock" setting for the baud rate register (set SBR to 0), then the baud-rate will be at 1/16th of the external clock. When you have a 1.8432MHz crystal this gives you the additional baudrate of 1843200/16 which is 115200baud. The 6551 does not know that he himselfs generates the clock at XTI :lol:.

By the way, as I don't have serial interfaces I mostly use http://shop.clickandbuild.com/cnb/shop/ftdichip?productID=49&op=catalogue-product_info-null&prodCategoryID=105 cables. They are also available with a 3v3 output. USB provides enough power for a CMOS based 65xx SBC,so I even power the SBCs from that cable, especially during setup and testing. Just make sure you use a inexpensive external USB Hub to protect your precious USB ports on the PC. This saves the MAX232 level converter.

Yes the 16550 complement pair of read and write enable signals can just be used as you said. Tying RD and WR to VCC and connect /RD and /WR to the respective signals created by the GAL should do the job.

cheers

Peter


Top
 Profile  
Reply with quote  
 Post subject: Re: RS232... here goes!
PostPosted: Thu Apr 16, 2015 7:44 pm 
Offline
User avatar

Joined: Fri Aug 30, 2002 1:09 am
Posts: 8510
Location: Southern California
Being able to reliably use just a crystal is part of the 51's design; and yes, it is totally reliable if you follow the rules and put the tiny capacitors in. [Edit: I see in a 2005 WDC data sheet that they had problems with the oscillator on the '51, and they recommended using an external oscillator. The Oct 2014 data sheet does not have this, so hopefully they got it fixed.]

The transmit-register-empty bug in WDC's '51 requires that you be sure to leave enough time to shift a byte out before writing another one. It's a disgrace that they introduced that bug; but it does not keep the whole thing from working.

The only thing I would recommend is using jumpers for selecting options, like:
  • whether or not to go through the line drivers and receivers
  • whether or not to use the hardware handshake inputs
  • choose between DCE and DTE (so you never have to use a null modem adapter)

_________________
http://WilsonMinesCo.com/ lots of 6502 resources
The "second front page" is http://wilsonminesco.com/links.html .
What's an additional VIA among friends, anyhow?


Top
 Profile  
Reply with quote  
 Post subject: Re: RS232... here goes!
PostPosted: Thu Apr 16, 2015 8:07 pm 
Offline
User avatar

Joined: Sun Sep 08, 2013 10:24 am
Posts: 740
Location: A missile silo somewhere under southern England
Looking at the 16550; I cannot determine what is the maximum clock speed that I can run it at (PHI2). Also, I don't think it needs a Max232 if I'm reading the datasheet correctly?

[edit] ok, so it basically accesses on /WR (WR) or /RD (RD) being asserted.
It looks ok to wire up, but the software side looks a bit iffy.

I'll take another look at the WDC W65C51N as you guys recommend as it is does seem simpler to use for a beginner.
With regard to the xmit bug; I'm really surprised that WDC haven't fixed it by now - 2 years on (rougly). I wouldn't expect them to withdraw existing stock, but I'd have expected some fix by now. Has anyone heard anything at all?


Top
 Profile  
Reply with quote  
 Post subject: Re: RS232... here goes!
PostPosted: Fri Apr 17, 2015 7:44 am 
Offline
User avatar

Joined: Sun Oct 13, 2013 2:58 pm
Posts: 491
Location: Switzerland
Hi banedon,

If you want to directly connect to a serial port of the PC (RS-232) you need a MAX232 or equivalent to shift the TTL logic levels of the 16550 to the RS-232 levels and protect the 16550 from the high voltages that RS-232 uses.

When interfacing the 16C550 to the 6502 you normally tie /AS (address strobe) to ground. So the relevant times are the longer address setup time (there are two setup times in the datasheet) and the strobe widths (for /IOR or /IOW) and the read or write cycle delay.

Then you have the following rules to obey:

    PHI2 low time must be at least address setup time of the 65C02 plus the address setup time of the 16C550
    PHI2 low time must be at least as long as read or write cycle delay
    PHI2 high must be at least /IOW or /IOR strobe width

these times depend heavily upon the manufacturer. The TI is a very slow example and PHI2 high and low phase would have to be at least 80ns, the total read or write cycle must be at least 175ns, which allows you to run the 65C02 only with approx 5 to 6MHz. The EXAR is twice as fast. And the EXAR supports 3V3 operation.

cheers

Peter


Top
 Profile  
Reply with quote  
 Post subject: Re: RS232... here goes!
PostPosted: Fri Apr 17, 2015 11:09 am 
Offline
User avatar

Joined: Sun Sep 08, 2013 10:24 am
Posts: 740
Location: A missile silo somewhere under southern England
Thanks Peter
The 16(C)550 is a 40 pin package. Added to that the 16 pin for the MAX232 and that's a lot of space on the board.
I'll stick with the W65C51N for now, although I think I might breadboard it at 1MHz or 500KHz for testing to get the hang of RS232C.


Top
 Profile  
Reply with quote  
 Post subject: Re: RS232... here goes!
PostPosted: Fri Apr 17, 2015 1:36 pm 
Offline
User avatar

Joined: Tue Mar 05, 2013 4:31 am
Posts: 1382
Re: the W65C51 xmit bug - I don't think they knew the bug was there initially. When I was tracking it down, I had some correspondence with WDC, they were not aware of any such problem and sent me the code they were using to test with. It was simply polling the xmit bit in the status register before sending another byte. Needless to say, they were not looking at the actual transmitted output. I used a logic analyzer and some coding to isolate the problem, then alerted WDC to what was the problem was. I agree that it's a shame but I don't see them correcting the problem and making a new batch of chips anytime soon.

Banedon,

If you still prefer to get your feet wet first using a 6551 chip, I suggest you source a few older Rockwell CMOS parts. I bought some from UTsource last year, all are 4MHz parts and they work perfectly. No reason to limit the CPU clock rates that low for initial testing. I also posted source for a 65C02 BIOS that supports the 65C02 and 65C22 chips.... the 65C51 BIOS supports full duplex and buffered xmit/rcv and is fully vectored for inserts along with a soft config capability. You can at least use it to test your hardware setup before writing your own code.

NOTES:
1- The Rockwell chips don't require the 1Meg resistor in parallel with the Xtal.
2- The Rockwell chips don't run reliably at speeds beyond 4MHz, which is a shame.
3- I've been running two systems non-stop for months with WDC W65C02, W65C22 and the Rockwell R65C51 chips at 4MHz. They have been 100% reliable.

_________________
Regards, KM
https://github.com/floobydust


Top
 Profile  
Reply with quote  
 Post subject: Re: RS232... here goes!
PostPosted: Fri Apr 17, 2015 8:00 pm 
Offline
User avatar

Joined: Sun Oct 13, 2013 2:58 pm
Posts: 491
Location: Switzerland
Hi banedon,

if you don't find a 4MHz Rockwell you can use the Harris/Intersil CDP65C51AE4, make sure it says 4 at the end for 4MHz. It is still available from many sources and it also works with 3V3. That's the one I normally use. On the other hand, one of BDDs favorite, like the SC26C92 (dual UART) in PDIP-40 works well together with 65xx CPUs and is quit fast (should work at least up to 7MHz).

Cheers

Peter


Top
 Profile  
Reply with quote  
 Post subject: Re: RS232... here goes!
PostPosted: Fri Apr 17, 2015 8:44 pm 
Offline
User avatar

Joined: Sun Sep 08, 2013 10:24 am
Posts: 740
Location: A missile silo somewhere under southern England
Thanks flooby & Peter. I don't currently have any Rockwell ones, but I'll have a look around to find what's out there (including the SC26C92).

In the meantime, here's how I think the WDC W65C51N should be connected up.
One thing which I'm not sure on is whether to tie RXC to VDD or VSS as it's a bidirectional port. Or just leave it?
Attachment:
w65c51n_rs232c.png
w65c51n_rs232c.png [ 23.02 KiB | Viewed 1708 times ]


Last edited by banedon on Fri Apr 17, 2015 9:02 pm, edited 1 time in total.

Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 49 posts ]  Go to page 1, 2, 3, 4  Next

All times are UTC


Who is online

Users browsing this forum: Google [Bot] and 9 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to: