I'm working on a VHDL implementation of the MBC3, with RTC. Everything's going great, it plays games just fine, but I'm struggling to read the RTC data.
I understand what the wiki says:
Code: Select all
[b]6000-7FFF - Latch Clock Data (Write Only)[/b] When writing 00h, and then 01h to this register, the current time becomes latched into the RTC registers. The latched data will not change until it becomes latched again, by repeating the write 00h->01h procedure. This is supposed for <reading> from the RTC registers. This can be proven by reading the latched (frozen) time from the RTC registers, and then unlatch the registers to show the clock itself continues to tick in background.
So my questions is: How do I latch the data safely? I noticed that the MBC3 uses the CLK signal from the cartridge edge, and I strongly suspect it is needed here for something. I'm not sure how to interface these two asynchronous clock domains.
I think the wiki says to wait 4 cycles in between latching and reading the RTC data? I'm not sure what requires 4 cycles to complete, but I assume it has to do with synchronizing some signal between these 2 domains?
Any help would be greatly appreciated, I can elaborate on anything else if needed.