Hi, I've read the wiki page and the linked data sheets on the EEPROM. I don't know much about electronics and I have trouble understanding what they say. Sorry for the long post, I have a few questions at the end. And here is what I understand for 24C02, please correct me if anything is wrong or missing:
1. To do anything, the game needs to get EEPROM out of STANDBY MODE. EEPROM recognizes this if SDA moves from low to high while SCL is high. The game does this by writing a sequence of bytes $40 $60 $20 to $800D where bit 6 is SCL and bit 5 is SDA.
2. EEPROM waits for the game to issue a single byte command. The low bit of the command determines whether it is a read command(low bit = 0) or a write command(low bit = 1).
3. EEPROM waits for the game to send a single byte address.
4. EEPROM waits for the game to send a single byte data for a write command or EEPROM sends a single byte of data for a read command.
5. To input each bit, the SCL goes from low to high and back, EEPROM take the state of SDA during that period as a bit value and write it to a temp location with high bit first. The game does this by writing $00 $20 $00 for 0 and $00 $40 $60 $40 $00 for 1.
From here on I'm a bit confused:
6. To read each bit, set the SDA high and then set bit 7 to high to get the value ready in bit 4. If SCL is set to low then the bit is read as an acknowledgement at the end of reading or writing a byte. Otherwise it is a read from the address sent by the game.
7. After the acknowledgement, the address will increment by 1 and the game can continue to read or write the next byte. To stop writing, send a stop signal after the acknowledgement. To stop reading, send a stop signal in place of the acknowledgement.
8. The EEPROM recognizes the stop signal if SDA moves from high to low while SCL is high. The game does this by writing a sequence of bytes $20 $60 $40 $C0.
Is the acknowledgement for a read command same as one for a write command?
Is the $C0 in the stop signal required?
Disch's doc says a read will not advance the bit and a write is required. Is that true?
Can someone show some example code where the whole byte is read?
What happens if the game does not follow the sequence? Do I need to care when writing an emulator?
Thanks.
1. To do anything, the game needs to get EEPROM out of STANDBY MODE. EEPROM recognizes this if SDA moves from low to high while SCL is high. The game does this by writing a sequence of bytes $40 $60 $20 to $800D where bit 6 is SCL and bit 5 is SDA.
2. EEPROM waits for the game to issue a single byte command. The low bit of the command determines whether it is a read command(low bit = 0) or a write command(low bit = 1).
3. EEPROM waits for the game to send a single byte address.
4. EEPROM waits for the game to send a single byte data for a write command or EEPROM sends a single byte of data for a read command.
5. To input each bit, the SCL goes from low to high and back, EEPROM take the state of SDA during that period as a bit value and write it to a temp location with high bit first. The game does this by writing $00 $20 $00 for 0 and $00 $40 $60 $40 $00 for 1.
From here on I'm a bit confused:
6. To read each bit, set the SDA high and then set bit 7 to high to get the value ready in bit 4. If SCL is set to low then the bit is read as an acknowledgement at the end of reading or writing a byte. Otherwise it is a read from the address sent by the game.
7. After the acknowledgement, the address will increment by 1 and the game can continue to read or write the next byte. To stop writing, send a stop signal after the acknowledgement. To stop reading, send a stop signal in place of the acknowledgement.
8. The EEPROM recognizes the stop signal if SDA moves from high to low while SCL is high. The game does this by writing a sequence of bytes $20 $60 $40 $C0.
Is the acknowledgement for a read command same as one for a write command?
Is the $C0 in the stop signal required?
Disch's doc says a read will not advance the bit and a write is required. Is that true?
Can someone show some example code where the whole byte is read?
What happens if the game does not follow the sequence? Do I need to care when writing an emulator?
Thanks.