Page 2 of 2

Re: Interfacing the 6522 and a Raspberry Pi

Posted: Mon Apr 11, 2022 11:15 pm
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.

Re: Interfacing the 6522 and a Raspberry Pi

Posted: Tue Apr 12, 2022 7:53 am
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!

Re: Interfacing the 6522 and a Raspberry Pi

Posted: Tue Apr 12, 2022 8:57 am
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.

Re: Interfacing the 6522 and a Raspberry Pi

Posted: Tue Apr 12, 2022 9:42 am
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.

Re: Interfacing the 6522 and a Raspberry Pi

Posted: Fri Apr 15, 2022 1:30 pm
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.

Re: Interfacing the 6522 and a Raspberry Pi

Posted: Fri Apr 22, 2022 8:50 am
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.