Skip to content

Commit 35eca2a

Browse files
authored
Update 7800.ino
Add clock generator usage to fix timing issues (thanks to @smesgr9000)
1 parent f947fb4 commit 35eca2a

File tree

1 file changed

+30
-4
lines changed

1 file changed

+30
-4
lines changed

Cart_Reader/7800.ino

+30-4
Original file line numberDiff line numberDiff line change
@@ -99,8 +99,8 @@ void setup_7800() {
9999
DDRL = 0xFF;
100100

101101
// Set Control Pins to Output
102-
// ---(PH0) CLK(PH1) ---(PH3) ---(PH4) ---(PH5) R/W(PH6)
103-
DDRH |= (1 << 0) | (1 << 1) | (1 << 3) | (1 << 4) | (1 << 5) | (1 << 6);
102+
// ---(PH0) ---(PH3) ---(PH4) ---(PH5) R/W(PH6)
103+
DDRH |= (1 << 0) | (1 << 3) | (1 << 4) | (1 << 5) | (1 << 6);
104104

105105
// Set TIME(PJ0) to Output (UNUSED)
106106
DDRJ |= (1 << 0);
@@ -109,8 +109,8 @@ void setup_7800() {
109109
DDRC = 0x00;
110110

111111
// Setting Control Pins to HIGH
112-
// ---(PH0) CLK(PH1) ---(PH3) ---(PH4) ---(PH5) R/W(PH6)
113-
PORTH |= (1 << 0) | (1 << 1) | (1 << 3) | (1 << 4) | (1 << 5) | (1 << 6);
112+
// ---(PH0) ---(PH3) ---(PH4) ---(PH5) R/W(PH6)
113+
PORTH |= (1 << 0) | (1 << 3) | (1 << 4) | (1 << 5) | (1 << 6);
114114

115115
// Set Unused Data Pins (PA0-PA7) to Output
116116
DDRA = 0xFF;
@@ -120,6 +120,32 @@ void setup_7800() {
120120
PORTL = 0xFF; // A16-A23
121121
PORTJ |= (1 << 0); // TIME(PJ0)
122122

123+
#ifdef clockgen_installed
124+
// Adafruit Clock Generator
125+
126+
initializeClockOffset();
127+
128+
if (!i2c_found) {
129+
display_Clear();
130+
print_FatalError(F("Clock Generator not found"));
131+
}
132+
133+
// Set Eeprom clock to 1Mhz
134+
clockgen.set_freq(200000000ULL, SI5351_CLK1);
135+
136+
// Start outputting Eeprom clock
137+
clockgen.output_enable(SI5351_CLK1, 1); // Eeprom clock
138+
139+
// Wait for clock generator
140+
clockgen.update_status();
141+
142+
#else
143+
// Set CLK(PH1) to Output
144+
DDRH |= (1 << 1);
145+
// Output a high signal CLK(PH1)
146+
PORTH |= (1 << 1);
147+
#endif
148+
123149
checkStatus_7800();
124150
strcpy(romName, "ATARI");
125151

0 commit comments

Comments
 (0)