Help understanding chip select sram pin

Discussion of programming and development for the original Game Boy and Game Boy Color.
Post Reply
Landfill
Posts: 3
Joined: Fri Aug 23, 2019 4:36 pm

Help understanding chip select sram pin

Post by Landfill »

A while back a created a working Gameboy rom dumper and I am now trying to add save dumping to it. I am having trouble finding information on the chip select pin, and what I need to do to it to read the sram. I have written code so far that:
-finds the number of sram banks
-enables ram banking mode
-enables ram
-reads data from address range for each bank
-disables ram

I have not messed with the CS pin, but I believe there is something I need to do with it to get this working. I am getting most of my information from GbdevWiki. Any help would be great.
lidnariq
Posts: 11430
Joined: Sun Apr 13, 2008 11:12 am

Re: Help understanding chip select sram pin

Post by lidnariq »

Treat the /CS pin as NOT(A15).

It isn't exactly, but as far as the cart's concerned it's close enough.
Landfill
Posts: 3
Joined: Fri Aug 23, 2019 4:36 pm

Re: Help understanding chip select sram pin

Post by Landfill »

I'm not sure I completely understand what you mean. I am wondering when I need to set the CS pin to high or low when accessing the sram.
lidnariq
Posts: 11430
Joined: Sun Apr 13, 2008 11:12 am

Re: Help understanding chip select sram pin

Post by lidnariq »

"A15" on the game boy cartridge connector isn't exactly A15 from the CPU. It's a signal that's low when the Game Boy is accessing $0000-$7FFF, but its timing is different from the rest of the address bus and it acts more like a bus enable signal. Similarly, "CS" is low when the Game Boy is accessing $A000-$FDFF, but it shares this same different timing with "A15".

Nothing on the cartridge cares about how /CS isn't low for $8000-$9FFF or $FE00-$FFFF. You can safely just treat /CS as though it were exactly the opposite of A15.
Landfill
Posts: 3
Joined: Fri Aug 23, 2019 4:36 pm

Re: Help understanding chip select sram pin

Post by Landfill »

so for me, interfacing directly to the cart to read and write the sram, I don't need to worry about the CS pin?
lidnariq
Posts: 11430
Joined: Sun Apr 13, 2008 11:12 am

Re: Help understanding chip select sram pin

Post by lidnariq »

That's not what I said. "A15" isn't an address line. It's just another enable, like /RD and /WR.

A15 or /CS or neither can be low, but never both. /RD or /WR or neither can be low, but never both. The bus is only active when one of the first two and one of the latter two are both active (low) simultaneously. Most MBCs place cart RAM in the region where /CS and A14 are both low (i.e. $A000-$BFFF), but I believe I read that at least one requires "A15" be high instead of /CS be low.
Post Reply