Data parallel buses

Discussion in 'Game Development General Discussion' started by andoba, Sep 5, 2007.

  1. andoba

    andoba Site Supporter 2014

    Joined:
    Sep 13, 2006
    Messages:
    1,256
    Likes Received:
    4
    Hello, well, you know some tutorial / page with some information for working with parallel data buses? For example, EPROM's, SRAM's, or something of the such.

    Whatever a tutorial for using such thing on a PIC or similar microcontroller, it would be VERY appreciated.

    All I found were serial EEPROM tutorials. Nothing else. :-(

    Thank you!
     
  2. Calpis

    Calpis Champion of the Forum

    Joined:
    Mar 13, 2004
    Messages:
    5,906
    Likes Received:
    21
    To use such a device, you just need to first place the address, assert /CE, then if you're reading, assert /OE (then grab the data at the data bus), or if you're writing, place data on the data bus and assert /WE. It's that simple! Just obey the timing constraints.

    /CE is the master enable. It allows you to use /OE (turns tri-state mode on data bus into outputs) or /WE (turns tri-state into inputs).

    For EPROMs you need a special programming voltage needed to blow fuses (make a bit a 0). For EEPROM it's just like SRAM. For Flash you need special programming algorithms that depend on the specific device.

    Edit: I should add that most MCU like PIC only have serial I/O, so it's really not practical to use parallel memory devices. If you really must, you could always use fancy bidirectional shift registers for data bits (and address/control or use counters for them) but that's pretty expensive and would be really slow since it'd be really tedious getting data in and out serially.
     
    Last edited: Sep 6, 2007
  3. marshallh

    marshallh N64 Coder

    Joined:
    Mar 16, 2006
    Messages:
    661
    Likes Received:
    26
    The only practical way to interface a PIC and say a SRAM or EEPROM is to either latch addresses into several shift registers, or integrate the shifters into a CPLD which would be cleaner.

    A PIC is really not meant to handle lots of I/O. A good starter kit would be a certain LPC2138 board, these are ARM chips and can run pretty fast, and have lots of I/O. They are also surface-mount.

    I would consider interfacing to CompactFlash card (possible with a pic16f877) or a SD card. You can google around and there are several tutorials/examples available.

    Maybe if you describe what you're trying to accomplish, I can recommend something.
     
  4. andoba

    andoba Site Supporter 2014

    Joined:
    Sep 13, 2006
    Messages:
    1,256
    Likes Received:
    4
    Well, thank you to you both.

    What I want to acomplish is writting and reading to a paralel data bus. Like, reading a byte from a EPROM, or writing to a SRAM.

    About the PIC not being appropiate, I'll look at some other microcontrollers.


    And calpis, thanks a lot. Then it should be something like this: I want to read a byte on the first bank:

    I pull CE high.
    I pull A0 high.
    I pull OE high.
    Then I read the byte from D0 to D7. I am right or wrong?

    Thank you :D
     
  5. Calpis

    Calpis Champion of the Forum

    Joined:
    Mar 13, 2004
    Messages:
    5,906
    Likes Received:
    21
    Not quite, you want to normally keep /CE and /OE high (inactive), to use it you must pull it low because it's /CE (the "/" denotes active low or an inverted input). /CE is needed so you can have multiple devices on the same data bus. To select the one to use, assert only that one's /CE. All ROM/SRAM's /OE should be connected together. If you make multiple devices output at the same time, you will have a bus conflict which could theoretically damage hardware. Even if there's only one device, it's a good idea to not keep /CE active when it's not being used because often chips have a low-power mode used when the chip is not selected!

    To read the first byte from a ROM:
    - pull A0-An low
    - pull /CE low
    - pull /OE low
    - wait for the speed of the ROM
    - read data

    To read the second byte do the same thing but A0 should be pulled high instead of low.

    If you're going to do a project just to learn, why not make a game cart dumper? You can use the PC's parallel port and use games instead of EPROMs or SRAM. This is a useful and cheap project if you have some programming experience.
     
    Last edited: Sep 6, 2007
  6. andoba

    andoba Site Supporter 2014

    Joined:
    Sep 13, 2006
    Messages:
    1,256
    Likes Received:
    4
    Oh, I'm used to recognise low signals with ! xD.

    And okay, thanks. About the cart dumper idea, yeah I could do that.

    The address thing does confuse me a bit.

    Imagine that I want to read a 8 mega bit cart (or a 8 mega bit EPROM). I know that it is organised in a role of 1 mbit * 8 bits. But, how do I know which address to pull low / high to read the desired byte?

    Calpis, you're helping me a lot. Thanks a lot! :D :D :D
     
    Last edited: Sep 6, 2007
  7. Calpis

    Calpis Champion of the Forum

    Joined:
    Mar 13, 2004
    Messages:
    5,906
    Likes Received:
    21
    For an 8Mbit ROM, there are 20 address lines or "bits". 2^20 = 1048576, 1048576 x 8 bits = 8 megabits. To read address X, just apply address X to the address lines. A0 is the least significant bit, A19 is the most significant.
     
  8. andoba

    andoba Site Supporter 2014

    Joined:
    Sep 13, 2006
    Messages:
    1,256
    Likes Received:
    4
    Oooh, I think i finally get it. For example, I want to read address FFFFFF (xD), I should do this:

    Pull A19 low.
    Pull CE low.
    Pull OE low.
    Wait.
    Read from the bus.

    I am right? :D

    Thanks a huge lot. You are awesome. Seriously.
     
    Last edited: Sep 6, 2007
  9. marshallh

    marshallh N64 Coder

    Joined:
    Mar 16, 2006
    Messages:
    661
    Likes Received:
    26
    Yes, that should do it. If you want to dump the whole thing, just increment a counter by 1 each iteration. You'll have to bitshift the bits in groups of 8 to each port on your MCU.

    If you want a MCU with lots of I/O and easy programming, sample a Cypress EZ-USB FX2. If you get the 100-pin tqfp, you get 40 I/O pins and it goes up to 48MHz, based on a 8051 core. You just wire it up to a USB socket and a 24mhz crystal, and 3.3v power source.

    Since your code is contained in 16kb of ram, programming happens in a split-second and automatically resets your chip.

    I'm sure you've seen destop's yan64bu. You can check the schematic to see how to wire it up.
     
  10. Calpis

    Calpis Champion of the Forum

    Joined:
    Mar 13, 2004
    Messages:
    5,906
    Likes Received:
    21
    I don't think you're getting it. 0xFFFFFF is byte 16777215 decimal, 0xFFFFF is the highest address in a 8M ROM. Address bits are active high. To read address 0x01234 you place this on the address bus:

    Code:
    0x0    1    2    3    4
    0000 0001 0010 0011 0100
    ^                      ^
    A19                    A0
     
  11. andoba

    andoba Site Supporter 2014

    Joined:
    Sep 13, 2006
    Messages:
    1,256
    Likes Received:
    4
    Okay, I don't get it. :'( Fuck.

    I asked a friend that was doing informatical engineering and he told me that:

    For getting the address you want to use, do: SD[DI], making a pointer on the first stack and moving it to the desired address... I don't get that.

    Shit, I blame my silliness.
     
  12. Calpis

    Calpis Champion of the Forum

    Joined:
    Mar 13, 2004
    Messages:
    5,906
    Likes Received:
    21
    Do you understand the number systems (decimal/binary/hex)? It's really very easy, look closely at my diagram. Just take the address you want to access, change it into binary, apply it to the address lines. To make any access, you must pull EACH address line high or low.

    This is why it's not a terribly good idea to use parallel buses with modern microcontrollers with few I/O. Old microcontrollers like the 8051 which were designed when EPROM was the only firmware storage, support external ROM/RAM naturally. Now the relatively large memory inside the chips makes it pretty unnecessary to have external devices and so they dropped that stuff in favor of having 8 pin devices.
     
    Last edited: Sep 7, 2007
  13. andoba

    andoba Site Supporter 2014

    Joined:
    Sep 13, 2006
    Messages:
    1,256
    Likes Received:
    4
    Then, for accesing A1CD26 I should do:

    1010 0001 1100 1101 0010 0110
    ^ ________________________^
    A19_______________________A0

    Right? :(
     
    Last edited: Sep 8, 2007
  14. Calpis

    Calpis Champion of the Forum

    Joined:
    Mar 13, 2004
    Messages:
    5,906
    Likes Received:
    21
  15. andoba

    andoba Site Supporter 2014

    Joined:
    Sep 13, 2006
    Messages:
    1,256
    Likes Received:
    4
    OH SHIT.

    THANKS! THANKS! YOU'RE AWESOME.
     
sonicdude10
Draft saved Draft deleted
Insert every image as a...
  1.  0%

Share This Page