Need Help with some UARTs

Building your first 6502-based project? We'll help you get started here.
gfoot
Posts: 871
Joined: 09 Jul 2021

Re: Need Help with some UARTs

Post by gfoot »

Yuri wrote:
So I think I may have noticed the issue here. The system comes up and runs, but when I tried plugging the serial cable into the 65C51 it refused to even boot. I started digging and the cheep bread board power supply I have is delivering 8.3V for some reason according to my meter. >_<

So, now to track down a better power supply.
Eek, is it one of the ones that plugs across the power rails and has a USB-A socket as well as a barrel jack? I've had the same thing, for a long time i was running my system at 7-8V as it appeared the voltage regulator had failed. At the time I thought it might have been due to me shorting it at some point, but it's hard to be sure when the system wasn't obviously broken afterwards.

Due to car battery issues in the past I had a device you plug in to the cigarette lighter socket with an LED display of the voltage it sees, which broke, but I took it to bits and rewired it to plug into the breadboard so now I have a permanent voltage display, which is good for peace of mind!
User avatar
Yuri
Posts: 371
Joined: 28 Feb 2023
Location: Texas

Re: Need Help with some UARTs

Post by Yuri »

Okay,

Things are pretty stable. The only issue I've run into is that it seems that if I have the 65C51 hooked up to my PC in anyway, it prevents the 65C02 from starting. It works fine if I connect the PC after the 65C02 has had a chance to start.

I've tried using a DTECH USB to TTL serial converter cable as well as my Arduino Due as a dummy pass thru serial port, and both have the same issue. If they're plugged into the system before power on, the 65C02 won't start. I have to disconnect them and power the thing down (reset doesn't work) and then back up.

I've checked the power rails and they appear to be good. (The current power module is delivering 4.97V)

All other things being equal, the code is working fine and the system has been very stable with the replaced ICs and power module.

I've attached the current version of the circuit with my IO devices. I'm pretty sure I need to tie down some other lines on there before I move on.
Attachments
io-circuit.png
cpu-circuit.png
barnacle
Posts: 1831
Joined: 19 Jan 2004
Location: Potsdam, DE
Contact:

Re: Need Help with some UARTs

Post by barnacle »

A shot in the dark, but... is your interrupt routine in eeprom or does it vector through ram? I'm wondering if there may be stray characters in the 6551 input buffer causing an interrupt which isn't being handled correctly...

Neil
User avatar
Yuri
Posts: 371
Joined: 28 Feb 2023
Location: Texas

Re: Need Help with some UARTs

Post by Yuri »

barnacle wrote:
A shot in the dark, but... is your interrupt routine in eeprom or does it vector through ram? I'm wondering if there may be stray characters in the 6551 input buffer causing an interrupt which isn't being handled correctly...

Neil
A good question, and one I had considered myself after I adjusted my serial program to output what it was reading to the LCD instead of looping it back. I saw quite a number of garbage characters come up when I had the serial port plugged in.

On the other hand though, it seems to not matter much if it's the receive line or the transmit line that's plugged in that causes it. Additionally, I don't think it's the interrupt line, as the 65C51 isn't (yet) connected to the IRQ1 pin on my NAND gates; that gate is currently tied hard to ground while I debug this stuff.

Right now my current working theory is I have some sort of odd grounding issue? I'll double check but I think I was able to reproduce by simply connecting the lines from the PC to some pull up resistors.

Pulling Up/Down the lines on the 65C51 end didn't have an effect.

I think the oddest part is that it works if I power on the 6502 w/o the lines connected and then connect them. At which point it behaves completely as expected (at least until I power it off)
mark.williams
Posts: 9
Joined: 27 May 2023

Re: Need Help with some UARTs

Post by mark.williams »

Perhaps your valid address decoding is allowing a clash on the data bus for when the UART is selected. I will have a look through your design and get back. Cheers Mark
User avatar
Yuri
Posts: 371
Joined: 28 Feb 2023
Location: Texas

Re: Need Help with some UARTs

Post by Yuri »

mark.williams wrote:
Perhaps your valid address decoding is allowing a clash on the data bus for when the UART is selected. I will have a look through your design and get back. Cheers Mark
Always open to a critical eye to make sure I didn't make a mistake anywhere, though I think BDD got it right with my mixing of logic families. Moving to HC parts settled most everything out. As for the weird interrupt issues, that seems to have calmed down.

I did figure out that I needed a pull up resistor on the 65C02's INT pin despite driving it with an IC. This was some head scratching on my part as the 65C02 datasheet doesn't seem to mention the open-drain nature of this pin, but the 65C22 docs seemed to suggest you should be using IC gates to drive the pin now and not the wire or with a diode (for performance reasons). But the interrupts weren't working until I added a pull up resistor; so it would seem I still need to wire or the logic?

Would be nice to get confirmation on that before I add more devices to the mix. Or when I switch to TTL which would let me use the 16550 which I think would be a nicer UART to use.

*shrug*
User avatar
floobydust
Posts: 1394
Joined: 05 Mar 2013

Re: Need Help with some UARTs

Post by floobydust »

I'm quite late to the party here....

Looking at the recent schematic pics, it appears you are using the W65C22N part along with the WD65C51N. Both of those parts have open drain IRQ outputs. As such, both parts require a pull-up resistor +5V. If you delete the two 74HC00 gates feeding the IRQ pin of the W65C02, you can just connect both IRQ outputs from the 'C22 and 'C51 to the CPU IRQ pin and all should be fine.
User avatar
cjs
Posts: 759
Joined: 01 Dec 2018
Location: Tokyo, Japan
Contact:

Re: Need Help with some UARTs

Post by cjs »

BigDumbDinosaur wrote:
I don’t do GitHub. I can never make head or tails out of it. :D
The easiest way of handling this is to click the "Code" button/dropdown and choose the "Download ZIP" option; this will give you a ZIP file with the latest version of the code from the branch you're looking at. (The default branch you see when you go to the project, often called `master` or `main`, is usually the one you want.)
gihub-download-zip.jpg
If you use Git, you can ignore all the GitHub functionality entirely and just clone the URL directly (git clone https://github.com/vhelin/wla-dx), treating it like any other URL (GitHub, GitLab, static site, whatever) that provides a Git repo via HTTP. I mostly do this, though I do find the ability of GitHub/GitLab/etc. to let you link directly to a page showing a file fairly useful when I want to show someone a particular bit of code without making them download anything. (And the ZIP download option is of course also useful for those who don't use Git.)

It's worth remembering that GitHub is not Git, no more than your HTTP hosting service is Vim (or your editor of choice for HTML files). One of the reasons GitHub is so popular is that, if you use only Git and not the GitHub-specific features, it's trivial to put up a copy of your repo anywhere else if GitHub starts doing things you don't like. (And a lot of repos did quickly move from GitHub to GitLab when MS bought GitHub.)
Curt J. Sampson - github.com/0cjs
mark.williams
Posts: 9
Joined: 27 May 2023

Re: Need Help with some UARTs

Post by mark.williams »

Yuri wrote:
mark.williams wrote:
Perhaps your valid address decoding is allowing a clash on the data bus for when the UART is selected. I will have a look through your design and get back. Cheers Mark
Always open to a critical eye to make sure I didn't make a mistake anywhere, though I think BDD got it right with my mixing of logic families. Moving to HC parts settled most everything out. As for the weird interrupt issues, that seems to have calmed down.

I did figure out that I needed a pull up resistor on the 65C02's INT pin despite driving it with an IC. This was some head scratching on my part as the 65C02 datasheet doesn't seem to mention the open-drain nature of this pin, but the 65C22 docs seemed to suggest you should be using IC gates to drive the pin now and not the wire or with a diode (for performance reasons). But the interrupts weren't working until I added a pull up resistor; so it would seem I still need to wire or the logic?

Would be nice to get confirmation on that before I add more devices to the mix. Or when I switch to TTL which would let me use the 16550 which I think would be a nicer UART to use.

*shrug*
mark.williams
Posts: 9
Joined: 27 May 2023

Re: Need Help with some UARTs

Post by mark.williams »

The 6502 is meant to be pin compatible with the 6800. The IRQ on the 6800 is wired or to allow multiple devices to interrupt the processor. Hope this helps in the final revision. Mark
rwiker
Posts: 294
Joined: 03 Mar 2011

Re: Need Help with some UARTs

Post by rwiker »

mark.williams wrote:
The 6502 is meant to be pin compatible with the 6800. The IRQ on the 6800 is wired or to allow multiple devices to interrupt the processor. Hope this helps in the final revision. Mark
6501, possibly?
User avatar
cjs
Posts: 759
Joined: 01 Dec 2018
Location: Tokyo, Japan
Contact:

Re: Need Help with some UARTs

Post by cjs »

Yes, the 6501 was designed to be pin-compatible with the 6800. That's long gone now, but it's fair to say that the 65xx series uses essentially the same bus protocol as Motorola's 8-bit processors, and so yes, the IRQ line is designed to be used with a pull-up and multiple devices with open-collector outputs.
Curt J. Sampson - github.com/0cjs
mark.williams
Posts: 9
Joined: 27 May 2023

Re: Need Help with some UARTs

Post by mark.williams »

Yes. I understabd the pin out changes that occured with the 6502 were to do with the clock circuitry and I assume the IRQ remained as wired or. NB The datasheets are silent on this :-( and (erroneously?) refer to them being driven by a std output.
User avatar
cjs
Posts: 759
Joined: 01 Dec 2018
Location: Tokyo, Japan
Contact:

Re: Need Help with some UARTs

Post by cjs »

mark.williams wrote:
Yes. I understabd the pin out changes that occured with the 6502 were to do with the clock circuitry...
Not just that, but also the removal of tri-state ability on the address bus. (In fact, both changes made also by Motorola a couple of years later with the 6802.) And maybe a few other things.
Quote:
and I assume the IRQ remained as wired or.
The IRQ pin on the 6502 is not "wired-or" or not since it's an input. Any input can be used in a wired-or configuration or not, because that's about the configuration the outputs feeding it, not the input.
Quote:
NB The datasheets are silent on this :-( and (erroneously?) refer to them being driven by a std output.
Well, I wouldn't expect that an input would mention whether you're to drive it with totem-pole or open-collector, since normally you can do both, but the March 1980 datasheet even explicitly mentions open collector usage: "A 3KΩ external resistor should be used for proper wire-OR operation."
Curt J. Sampson - github.com/0cjs
User avatar
BigDumbDinosaur
Posts: 9425
Joined: 28 May 2009
Location: Midwestern USA (JB Pritzker’s dystopia)
Contact:

Re: Need Help with some UARTs

Post by BigDumbDinosaur »

mark.williams wrote:
Yes. I understabd the pin out changes that occured with the 6502 were to do with the clock circuitry and I assume the IRQ remained as wired or. NB The datasheets are silent on this :-( and (erroneously?) refer to them being driven by a std output.

The primary reason the 6501 pinout was changed was Motorola sued MOS Technology for patent infringement and as part of the settlement, the latter agreed to change the 6501 so it couldn't be plugged into an MC6800 board. The result was the “lawsuit-compatible” 6502.

All members of the 6502 family have been designed to use a wired-OR interrupt circuit, excepting WDC’s 65C22S, which has a totem-pole IRQ output and hence can’t be wired-OR without the use of a blocking diode. A better implementation has the 65C22S driving one of the inputs of an AND gate, and another input of the same gate wired-OR to the other interrupting devices in the system. The gate’s output drives the IRQB pin on the MPU—no pullup resistor required.
x86?  We ain't got no x86.  We don't NEED no stinking x86!
Post Reply