6502 and 16550 UART Problem
Re: 6502 and 16550 UART Problem
Just want to post an update because I ran into more problems that I could however solve meanwhile and maybe my solutions help someone else in the future.
After having the UART up and running I wrote some nice functions (and therefore used JRE PHA PLA instructions) to send and receive characters and things went completely mysterious again, echoing back random characters or just two characters instead of a much longer string. As soon as I stopped using anything stack related things worked again. In other words everything stopped working as soon as I started writing to the RAM. I suspected my address and \RD \WR decoding logic before so that's where I started to look for problems. While reading on the topic I stumbled across things like clock skew and logic timing related problems, especially in connection with PHO2.
Long story short replacing the 74HCT04 with a much slower but pin compatible CD40106 solved the problem and everything works just fine.
My theory here is that with the 74HCT04 \WR was probably pulled down way before the address I wanted to write to was stable.
After having the UART up and running I wrote some nice functions (and therefore used JRE PHA PLA instructions) to send and receive characters and things went completely mysterious again, echoing back random characters or just two characters instead of a much longer string. As soon as I stopped using anything stack related things worked again. In other words everything stopped working as soon as I started writing to the RAM. I suspected my address and \RD \WR decoding logic before so that's where I started to look for problems. While reading on the topic I stumbled across things like clock skew and logic timing related problems, especially in connection with PHO2.
Long story short replacing the 74HCT04 with a much slower but pin compatible CD40106 solved the problem and everything works just fine.
My theory here is that with the 74HCT04 \WR was probably pulled down way before the address I wanted to write to was stable.
- BigDumbDinosaur
- Posts: 9428
- Joined: 28 May 2009
- Location: Midwestern USA (JB Pritzker’s dystopia)
- Contact:
Re: 6502 and 16550 UART Problem
maewn21 wrote:
Long story short replacing the 74HCT04 with a much slower but pin compatible CD40106 solved the problem and everything works just fine.
My theory here is that with the 74HCT04 \WR was probably pulled down way before the address I wanted to write to was stable.
My theory here is that with the 74HCT04 \WR was probably pulled down way before the address I wanted to write to was stable.
Your theory may be correct and if so, is telling you your glue logic design is incorrect.
Succinctly stated, the device—UART in this case—should be selected without reference to the state of Ø2. The 65C02 generates a valid address midway through Ø2 low. Glue logic should take advantage of that to maximize timing headroom. As a fairly general rule, the device's /CS should be asserted before /RD (read data) or /WD is asserted. Aside from guaranteeing the correct register has been selected before a read or write operation, following this rule may improve device performance in some cases, as many devices' response to /CS is slower than to /RD or /WD. In the case of E(E)PROMs, this difference may be considerable.
Note that the 65xx-compatible I/O devices—65C22, 65C51, etc.—must not have any aspect of their operation qualified by Ø2. As those devices have a dedicated Ø2 input, they will "know" about the 65C02 bus cycle and will not sample RWB until Ø2 goes high.
x86? We ain't got no x86. We don't NEED no stinking x86!
Re: 6502 and 16550 UART Problem
BigDumbDinosaur wrote:
maewn21 wrote:
Long story short replacing the 74HCT04 with a much slower but pin compatible CD40106 solved the problem and everything works just fine.
My theory here is that with the 74HCT04 \WR was probably pulled down way before the address I wanted to write to was stable.
My theory here is that with the 74HCT04 \WR was probably pulled down way before the address I wanted to write to was stable.
Your theory may be correct and if so, is telling you your glue logic design is incorrect.
Succinctly stated, the device—UART in this case—should be selected without reference to the state of Ø2. The 65C02 generates a valid address midway through Ø2 low. Glue logic should take advantage of that to maximize timing headroom. As a fairly general rule, the device's /CS should be asserted before /RD (read data) or /WD is asserted. Aside from guaranteeing the correct register has been selected before a read or write operation, following this rule may improve device performance in some cases, as many devices' response to /CS is slower than to /RD or /WD. In the case of E(E)PROMs, this difference may be considerable.
Note that the 65xx-compatible I/O devices—65C22, 65C51, etc.—must not have any aspect of their operation qualified by Ø2. As those devices have a dedicated Ø2 input, they will "know" about the 65C02 bus cycle and will not sample RWB until Ø2 goes high.
My \CS signals are not qualified by Ø2 as you can see in the schematic I've posted when I started this thread. The only things that I qualify by Ø2 are \RD \WR. Still looking at the timing diagrams in the 6502 datasheet I figured that Ø2 goes high long before anything on the data bus is valid and if I understand that right, this should'nt matter when reading from ROM but may write whatever is on the data bus into the RAM if it's fast enough. 15ns RAM in my case. (I may have actually mixed up data bus and address bus when posting my update, I didn't have the datasheet open at this time. Sorry for that)
I'm using an NMOS 6502 (just guess it's NMOS. it draws ~100mA, gets quite warm, it's sanded off and relabeled). Not sure if that makes any difference with the timing compared to the CMOS version.
About the UART, after fixing that timing problem I tried the UART chips that I declared dead and they still only send out gibberish. So them not working wasn't caused by the timing issue.
Anyways it's working now and I have adapted the Intel hex loader from the code section of the site to work with the 16550. So I can finally just copy paste hex files into putty instead of swapping the ROM all the time. I do however think about putting some jumpers on the now grounded and unused address lines of the ROM so I could easily switch between a few programs besides the hex loader. Some version of Basic comes to mind and maybe something to dump the RAM contents thru the serial port.
- BigDumbDinosaur
- Posts: 9428
- Joined: 28 May 2009
- Location: Midwestern USA (JB Pritzker’s dystopia)
- Contact:
Re: 6502 and 16550 UART Problem
maewn21 wrote:
I'm using an NMOS 6502 (just guess it's NMOS. it draws ~100mA, gets quite warm, it's sanded off and relabeled). Not sure if that makes any difference with the timing compared to the CMOS version.
I haven't looked at the NMOS data sheet in many years, so I can't comment about any timing variances vis a vis the CMOS hardware. However, I will note that the NMOS 6502's outputs only drive to TTL levels, and rather weakly, at that. This characteristic can, in conjunction with parasitic capacitance, mung up timing in often-bewildering ways. You really need to switch to the 65C02 or 65C816 and ditch the NMOS hardware.
x86? We ain't got no x86. We don't NEED no stinking x86!
- GARTHWILSON
- Forum Moderator
- Posts: 8774
- Joined: 30 Aug 2002
- Location: Southern California
- Contact:
Re: 6502 and 16550 UART Problem
I summarize the many differences between the NMOS 6502 and the CMOS at http://wilsonminesco.com/NMOS-CMOSdif/ .
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?
The "second front page" is http://wilsonminesco.com/links.html .
What's an additional VIA among friends, anyhow?
Re: 6502 and 16550 UART Problem
GARTHWILSON wrote:
I summarize the many differences between the NMOS 6502 and the CMOS at http://wilsonminesco.com/NMOS-CMOSdif/ .
BigDumbDinosaur wrote:
maewn21 wrote:
I'm using an NMOS 6502 (just guess it's NMOS. it draws ~100mA, gets quite warm, it's sanded off and relabeled). Not sure if that makes any difference with the timing compared to the CMOS version.
I haven't looked at the NMOS data sheet in many years, so I can't comment about any timing variances vis a vis the CMOS hardware. However, I will note that the NMOS 6502's outputs only drive to TTL levels, and rather weakly, at that. This characteristic can, in conjunction with parasitic capacitance, mung up timing in often-bewildering ways. You really need to switch to the 65C02 or 65C816 and ditch the NMOS hardware.
Would pull-up resistors 4k7 or 10k on data, address bus and all the other outputs actually do any good in terms of improving the signals?
- BigDumbDinosaur
- Posts: 9428
- Joined: 28 May 2009
- Location: Midwestern USA (JB Pritzker’s dystopia)
- Contact:
Re: 6502 and 16550 UART Problem
maewn21 wrote:
I thought TTL levels should not be a problem with the 74HCT series.
They aren't a problem—if the signal seen at the input of the 74HCT device is a sharply-defined square wave. However, parasitic capacitance can slow the rise and fall times of a signal to where the transition from a logic 0 to logic 1, or vice versa, is too slow for the device receiving the signal. The rise time is particularly problematic with a weak TTL driver like the NMOS 6502, as it cannot pull up toward Vcc nearly as hard as it can pull down toward ground.
Quote:
A W65C02 or W65C816 was what I actually wanted, however there is no local retailer selling any sort of 65xx IC's...
If you add your location to your forum profile perhaps someone can advise you on where to get the genuine WDC products.
Quote:
...so all I am left with are eBay and similar sites...
You need to be very cautious about ordering a 65C02 from an eBay seller. If it is described as a WDC product the odds are you will receive a counterfeit part. Genuine WDC parts are sold only through authorized distributors. In particular, David Gray at WDC has emphatically stated that no one in China is an authorized distributor or reseller of WDC products. Please keep that in mind before you buy from an eBay reseller.
Quote:
Would pull-up resistors 4k7 or 10k on data, address bus and all the other outputs actually do any good in terms of improving the signals?
I doubt it.
x86? We ain't got no x86. We don't NEED no stinking x86!
Re: 6502 and 16550 UART Problem
Quote:
If you add your location to your forum profile perhaps someone can advise you on where to get the genuine WDC products.
Re: 6502 and 16550 UART Problem
Mouser in Thailand (Bangkok) seems to have genuine WDC products.
Mouser also has 16C550 UARTs in PLCC package (not in DIP package).
Digikey in Thailand seems to have genuine TL16C550BN (Texas Instruments) UARTs from Rochester Electronics in DIP package,
but it looks like TI isn't manufacturing the TL16C550 in DIP package anymore: if that stock is gone, it's gone.
Mouser also has 16C550 UARTs in PLCC package (not in DIP package).
Digikey in Thailand seems to have genuine TL16C550BN (Texas Instruments) UARTs from Rochester Electronics in DIP package,
but it looks like TI isn't manufacturing the TL16C550 in DIP package anymore: if that stock is gone, it's gone.
Re: 6502 and 16550 UART Problem
ttlworks wrote:
Mouser in Thailand (Bangkok) seems to have genuine WDC products.
Mouser also has 16C550 UARTs in PLCC package (not in DIP package).
Digikey in Thailand seems to have genuine TL16C550BN (Texas Instruments) UARTs from Rochester Electronics in DIP package,
but it looks like TI isn't manufacturing the TL16C550 in DIP package anymore: if that stock is gone, it's gone.
Mouser also has 16C550 UARTs in PLCC package (not in DIP package).
Digikey in Thailand seems to have genuine TL16C550BN (Texas Instruments) UARTs from Rochester Electronics in DIP package,
but it looks like TI isn't manufacturing the TL16C550 in DIP package anymore: if that stock is gone, it's gone.
I did not know about Digikey and had a look. However the minimum order amount for the UART's you linked to is 85 pieces which is far more than I likely ever need. Since I do electronics just as a Hobby.
By the way, I did know that TI does not manufacture 16C550 in DIP-40 packages anymore, I stumbled upon this fact as I was looking for a datasheet since the only one I could find for the Ei16C550 (the dead one) is not really detailed and even shows wrong pin outs. (shows pin 19=VSS instead of RD ,and pin 20=nothing instead of VSS for the DIP package which is obviously wrong but not important since both are connected to GND in my case anyways)
Does Digikey usually only sell larger quantities?
- BigDumbDinosaur
- Posts: 9428
- Joined: 28 May 2009
- Location: Midwestern USA (JB Pritzker’s dystopia)
- Contact:
Re: 6502 and 16550 UART Problem
maewn21 wrote:
The shipping price of ~18 USD (translated from 600 THB) I quoted before from was from Mouser Thailand branch, together with the long estimated delivery time of ~2 weeks my guess is they don't have a local stock of WDC parts.
More likely than not, your order would be fulfilled from Mouser's US warehouse. That would explain the two week delivery time and 600 THB shipping cost.
Quote:
Does Digikey usually only sell larger quantities?
The reason for the minimum is that Digikey part is sourced from Rochester Electronics, an obsolete parts liquidator. In this instance, Digikey is acting as a reseller, not a distributor. All orders processed through Rochester incur relatively large minimums. Rochester is definitely not hobby-friendly.
x86? We ain't got no x86. We don't NEED no stinking x86!
Re: 6502 and 16550 UART Problem
Sorry that:
From the Digikey page, to me it didn't come out clear that the TL16C550BN minimum quantity is 85 chips.
Mouser is the only distributor for WDC parts I was able to find in Thailand.
Hmm... when I had been into hobby electronics, availability of chips in DIP package became quite a topic, so at some point I had started to buy chips for 20 years in advance.
When I had stopped with hobby tinkering, I donated my collection of chips to a forum member...
From the Digikey page, to me it didn't come out clear that the TL16C550BN minimum quantity is 85 chips.
Mouser is the only distributor for WDC parts I was able to find in Thailand.
Hmm... when I had been into hobby electronics, availability of chips in DIP package became quite a topic, so at some point I had started to buy chips for 20 years in advance.
When I had stopped with hobby tinkering, I donated my collection of chips to a forum member...
Re: 6502 and 16550 UART Problem
BigDumbDinosaur wrote:
The reason for the minimum is that Digikey part is sourced from Rochester Electronics, an obsolete parts liquidator. In this instance, Digikey is acting as a reseller, not a distributor. All orders processed through Rochester incur relatively large minimums. Rochester is definitely not hobby-friendly.
ttlworks wrote:
Sorry that:
From the Digikey page, to me it didn't come out clear that the TL16C550BN minimum quantity is 85 chips.
Mouser is the only distributor for WDC parts I was able to find in Thailand.
Hmm... when I had been into hobby electronics, availability of chips in DIP package became quite a topic, so at some point I had started to buy chips for 20 years in advance.
When I had stopped with hobby tinkering, I donated my collection of chips to a forum member...
From the Digikey page, to me it didn't come out clear that the TL16C550BN minimum quantity is 85 chips.
Mouser is the only distributor for WDC parts I was able to find in Thailand.
Hmm... when I had been into hobby electronics, availability of chips in DIP package became quite a topic, so at some point I had started to buy chips for 20 years in advance.
When I had stopped with hobby tinkering, I donated my collection of chips to a forum member...
Re: 6502 and 16550 UART Problem
There are Rockwell R65C02 chips at ebay, but wheter they are fully functional originals or not would be going to be a different topic.
- BigDumbDinosaur
- Posts: 9428
- Joined: 28 May 2009
- Location: Midwestern USA (JB Pritzker’s dystopia)
- Contact:
Re: 6502 and 16550 UART Problem
maewn21 wrote:
Either ordering a larger amount of 65C02 from Mouser to make it worth the shipping cost, or keep trying my luck with the likes of eBay where I probably could get at best a non WDC CMOS version.
I will reiterate that you need to be very cautious about ordering a 65C02 from an eBay seller. Not knowing the true provenance of such parts, you could end up with a remarked NMOS device or worse yet, a defective one that causes damage to other parts of your machine. My recommendation is if you see any evidence of the seller being Chinese ("from China" on the auction page, for example) DO NOT BUY IT!
x86? We ain't got no x86. We don't NEED no stinking x86!