Interfacing the 6522 and a Raspberry Pi

For discussing the 65xx hardware itself or electronics projects.
User avatar
GARTHWILSON
Forum Moderator
Posts: 8775
Joined: 30 Aug 2002
Location: Southern California
Contact:

Re: Interfacing the 6522 and a Raspberry Pi

Post by GARTHWILSON »

gfoot wrote:
Yes, but watch out for that bus holding device - it will weakly drive the bus to retain its last state, if nothing else is driving it more strongly. This could interfere with what you're doing as well. It might be weak enough that it doesn't matter.
Fortunately the maximum current there is only 20µA low, and 9µA high, so pretty minimal.
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?
User avatar
speculatrix
Posts: 151
Joined: 03 Apr 2018
Contact:

Re: Interfacing the 6522 and a Raspberry Pi

Post by speculatrix »

Thanks for the feedback guys.

In case you're at all curious, what I'm implementing here is a mass storage device for my 6502 machine. And my disk drive of choice is a Raspberry Pi Zero 2 W. I'm using Port A of the 6522 as an eight-bit parallel data bus and the other port for control lines.

So far, typing LOAD on the 6502 will request a file (always the same file thus far) from the Pi. At the moment, it sends only the first byte, because that's as far as I've got. Everything is bit-banged.

Why not implement an SPI interface and use an SD card or a CF card or some such? I felt like designing a solution and a protocol all my own because that's what constitutes fun to me. This approach means that I can create a program on any computer I like and drop it into a folder on the RPi over the network. No removing/replacing of cards.

Yes, my solution might be slow, flaky and inefficient, but it will be mine dammit!
It either works or catches fire. Either way is fun.
Zolatron 64 project (on Medium)
gfoot
Posts: 871
Joined: 09 Jul 2021

Re: Interfacing the 6522 and a Raspberry Pi

Post by gfoot »

I get it, sometimes you need to kind of invent a problem to make an excuse to build something or write some code!

In your position with full freedom to design both ends of the interface I'd probably have been more inclined to make the data lines unidirectional, at least as a first pass, as it would dodge a lot of the buffering issues - you could have made your interface open-drain at both ends, like the floppy disc interface is, which means nobody needs to care much what voltage the other side of the interface is using. Each signal is either pulled low, or it's not; and the receiving side does the pull-up to whatever voltage it needs to register high.

But it sounds like you've already got it working now so that's great.
User avatar
speculatrix
Posts: 151
Joined: 03 Apr 2018
Contact:

Re: Interfacing the 6522 and a Raspberry Pi

Post by speculatrix »

Just to add, I now have the load routine working and it's capable of loading a 56-byte program in a mere fraction of a fortnight.
It either works or catches fire. Either way is fun.
Zolatron 64 project (on Medium)
User avatar
Sheep64
In Memoriam
Posts: 311
Joined: 11 Aug 2020
Location: A magnetic field

Re: Interfacing the 6522 and a Raspberry Pi

Post by Sheep64 »

If possible, uni-directional level conversion is preferable.
speculatrix on Sat 2 Apr 2022 wrote:
I did also wonder about using a 3V3 Zener attached between each line and ground.
That is a safe option, especially if excessive voltage may occur. A 0.5V Zener or similar may be useful for negative voltage.
User avatar
speculatrix
Posts: 151
Joined: 03 Apr 2018
Contact:

Re: Interfacing the 6522 and a Raspberry Pi

Post by speculatrix »

For the sake of completeness, I thought I'd mention where I ended up with this.

For the control signals, I'm using simple resistor voltage dividers (2k2 and 3k3 resistors), even for the 3.3V signals coming from the Raspberry Pi to the 65C22.

I was doing the same for the bidirectional data bus. But it was going to mean a lot of resistors on the final PCB. However, I finally got my hands on the 74LVC4245. This is bidirectional, with the direction being selected via a DIR pin. I hooked up a spare signal from the 6522 to this and it works great!

Full details here and here.
It either works or catches fire. Either way is fun.
Zolatron 64 project (on Medium)
Post Reply