[ans]SNES Exact SRAM Write Protocol?

This is an archive of a topic from NESdev BBS, taken in mid-October 2019 before a server upgrade.
View original topic
[ans]SNES Exact SRAM Write Protocol?
by on (#116070)
Hi guys. I have been building a SNES Cart Interface circuit that uses an Atmel AVR (ATmega8515). This weekend I added functionality to Read/Write SRAM. Let me tell you, the SRAM Write routine has been very tough on me.

Please check out these specifics so you can see my design.

I have /CART Permanently Low (grounded). This is the CHIP ENABLE(s).
For the ROM read,
1) /READ line low, set it once for the rest of the routine.

then in a loop:
2) Set Address
3) Get Data

works great
Worked the same for the SRAM Read.
I could not do the same for the SRAM Write
I currently have the functionality apparently unextensively tested, TESTED with Super Mario World 16 Kbit SRAM. Works 99%, but the very first byte at $70:0000 will be written as $FF every time. I have tried a number of strategies but nothing works. Any help??

Here is my current strategy:
1) Set Read/Write both high, Cart LOW (connected to ground). I don't have any more i/o for /CART but I did try for the hell of it and connected it where /READ was for an exclusive Write test. I tried a couple orders of writing with different assortments of positioning for deactivating and activating /CART with /WRITE. nothing solved it.

2) Set Data i/o to be output lines
3) enter loop:
4) Assign address
5) /WRITE low
6) Get char from UART, puting into DATA lines
7) /WRITE high

This works for 99% of the SRAM but like I said, the very first address doesn't budge from erroneous $FF.
Before I tried this routine without setting/unsetting /WRITE, I had a couple other error writes, on the first 3 pages of $100 (70:0000, 70:0100, 70:0200 were the only errors at the time). Then I added the code to alter /WRITE every iteration which saved all errors except for the first like I have been saying.

I have tried elaborate schemes to bypass this. I tried hooking up /CART to my mcu and a couple different styles of setting it low before/during the writing process. Maybe I didn't find the magic one. Can anyone give me that please? Sheesh. I'm lost without it. I'm determined.

I also tried writing first to $70:0001 to possibly "get it rolling" then moved back to $70:0000, but it still wrote the $FF value to that location. Ugh.. stressed out. Don't want to come here, love solving problems on my own.. However, after ~800 attempts or more, I am here.
Re: SNES Exact SRAM Write Protocol?
by on (#116074)
Hey Guys I fixed it :)

Had to disable the Analog Comparator of my MCU. :mrgreen:
Re: SNES Exact SRAM Write Protocol?
by on (#116285)
I think the correct way would be to output address and data, and *THEN* switch /write low, and then back high.
Ie. address and data should be valid & stable during /write=low period.

Datasheets contain detailed signal timing diagrams. For example, enter your sram part number at http://www.datasheetarchive.com/
Re: SNES Exact SRAM Write Protocol?
by on (#116347)
Thank you, while you are most certainly right about that, I already have a 100% functional programming, so I would rather not mess with it. In the future, I will take good care of these considerations.