Shop OBEX P1 Docs P2 Docs Learn Events
I need to connect my propeller to a data bus. How do I read the values? — Parallax Forums

I need to connect my propeller to a data bus. How do I read the values?

cbmeekscbmeeks Posts: 634
edited 2015-03-17 21:38 in Propeller 1
Sorry, I know that sounds like a strange question.

BTW, the community has been great here. Now that I have sweetened the pot, I shall ask another question. :-)

So I am working on building a Mockingboard clone that will be an add-on card to an Apple IIe. I have built one on a breadboard using nothing but legacy parts (AY-3-8912 and 6522 VIA).

But after I found the wonderful SIDCog, AYCog and SNECog, I want to build one that uses nothing but new parts. Should bring new life into the Apple II scene if everyone can easily get modern sound cards. lol

Anyway, I need to develop a replacement for the 6522 VIA chip. The way it works is that it has an 8 bit data bus and I think 4-6 bits from the 16 bit address bus (not all pins are used).

Now, say the Apple (through some game) sends $FF to the data bus. This will of course send 5v high to 8 different pins that I plan on connecting to the propeller (through a level shifter).

But how do I determine that pins X1 - X8 should translate to 256? Or that pins X1 and X2 should be 3?

I'd like to do this in spin because I don't think something as simple as sending data to the 6522 needs asm. Sorry for being such a newbie. Surely there is an easy way to read in X number of pins?

Thanks

Comments

  • Duane DegnDuane Degn Posts: 10,588
    edited 2015-03-17 08:51
    Let's assume your 8-bit bus is on pins 8 (named "LSB_PIN") through 15 (named "MSB_PIN").
    dataByte := ina[MSB_PIN..LSB_PIN]
    

    Any 8 consecutive I/O pins could have been used.

    In PASM, you'd need to shift the bits after capturing them (you have to capture all 32-bits in PASM). This is why it's common to start multiple pin data buses on pin 0 (you don't need to shift it).
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2015-03-17 09:01
    The bus state will probably be too fleeting to capture in Spin without help from some additional hardware like a data latch (74HCT373, for example). This would use one of the select or strobe lines to capture the data long enough for Spin to read it. Your Spin program would be doing a waitpeq on the same pin that latches the data (and perhaps additional address lines) in order to know when the new data is available at the selected address.

    -Phil
  • cbmeekscbmeeks Posts: 634
    edited 2015-03-17 10:07
    Thank you both for your replies.

    The first thing I need to do is simply grab a bunch of data from the address/data bus to see how the games use the card. So I should be able to use the console for that.

    Are there any example programs out there that can show me how to do that? Basically, read in the bits and print to the console? IIRC, the Apple has a pin (IOSEL, I think) that basically goes low when the card is activated. After that, there is a 1Mhz (or so) clock that would probably be used to fire any reads/writes. I guess I could tie to that pin as my latch (or something similar).

    Once latched, I would need to decode all 24 pins and send the data to the terminal.

    Thanks for any examples.
  • Bill HenningBill Henning Posts: 6,445
    edited 2015-03-17 21:24
    As I recall, the 6502 in the apple had a 1MHz clock, but only used every second memory cycle as the video circuitry used the alternate cycles.

    A range of memory was decoded for the slots, which generated IOSEL when the IO range was used - I forget the size of the IO space, see if you can find a copy of the "Mapping the Apple ][" book, that was good as I recall.

    I am not sure the prop can respond fast enough, waitpeq/pne take six clock cycles, then you have to decode the low address bits, and make a reply... at 100Mhz 500ns is 50 propeller clocks, so as long simple responses may be possible.
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2015-03-17 21:38
    For reads, you can always insert WAIT states by latching RDY low right away:

    Then, when the Prop is good and ready with data on D0-D7, it can set RDY high.

    -Phil
Sign In or Register to comment.