From ba2893c9162af371199b4186336fcce8221b3a55 Mon Sep 17 00:00:00 2001 From: bootsector Date: Thu, 25 Dec 2025 04:48:43 -0500 Subject: [PATCH 1/4] 7800.ino - Allow the user to enable/disable the clock generator, if present, through the menu. --- Cart_Reader/7800.ino | 70 ++++++++++++++++++++++++++++++-------------- Cart_Reader/OSCR.cpp | 2 ++ Cart_Reader/OSCR.h | 2 ++ 3 files changed, 52 insertions(+), 22 deletions(-) diff --git a/Cart_Reader/7800.ino b/Cart_Reader/7800.ino index ef4058e6..f039b980 100644 --- a/Cart_Reader/7800.ino +++ b/Cart_Reader/7800.ino @@ -77,11 +77,15 @@ byte a7800size; // 07 MAPPER // 08 ROM SIZE +bool enable_clockgen = false; + //****************************************** // Menu //****************************************** // Base Menu static const char* const menuOptions7800[] PROGMEM = { FSTRING_SELECT_CART, FSTRING_READ_ROM, FSTRING_SET_SIZE, FSTRING_RESET }; +// Clock Gen Menu +static const char* const menuClockGen7800[] PROGMEM = { FSTRING_CLKGEN_OFF, FSTRING_CLKGEN_ON }; void setup_7800() { // Request 5V @@ -118,31 +122,30 @@ void setup_7800() { PORTL = 0xFF; // A16-A23 PORTJ |= (1 << 0); // TIME(PJ0) -#ifdef ENABLE_CLOCKGEN - // Adafruit Clock Generator - - initializeClockOffset(); + if (enable_clockgen) { + // Adafruit Clock Generator - if (!i2c_found) { - display_Clear(); - print_FatalError(F("Clock Generator not found")); - } + initializeClockOffset(); - // Set Eeprom clock to 1Mhz - clockgen.set_freq(200000000ULL, SI5351_CLK1); + if (!i2c_found) { + display_Clear(); + print_FatalError(F("Clock Generator not found")); + } - // Start outputting Eeprom clock - clockgen.output_enable(SI5351_CLK1, 1); // Eeprom clock + // Set Eeprom clock to 1Mhz + clockgen.set_freq(200000000ULL, SI5351_CLK1); - // Wait for clock generator - clockgen.update_status(); + // Start outputting Eeprom clock + clockgen.output_enable(SI5351_CLK1, 1); // Eeprom clock -#else - // Set CLK(PH1) to Output - DDRH |= (1 << 1); - // Output a high signal CLK(PH1) - PORTH |= (1 << 1); -#endif + // Wait for clock generator + clockgen.update_status(); + } else { + // Set CLK(PH1) to Output + DDRH |= (1 << 1); + // Output a high signal CLK(PH1) + PORTH |= (1 << 1); + } checkStatus_7800(); strcpy(romName, "ATARI"); @@ -151,8 +154,29 @@ void setup_7800() { } void a7800Menu() { + uint8_t mainMenu; + +#ifdef ENABLE_CLOCKGEN + convertPgm(menuClockGen7800, 2); + mainMenu = question_box(F("ATARI 7800 MENU"), menuOptions, 2, 0); + + switch (mainMenu) { + case 0: + // Disable Clock Gen + enable_clockgen = false; + break; + + case 1: + // Enable Clock Gen + enable_clockgen = true; + break; + } + + setup_7800(); +#endif + convertPgm(menuOptions7800, 4); - uint8_t mainMenu = question_box(F("ATARI 7800 MENU"), menuOptions, 4, 0); + mainMenu = question_box(F("ATARI 7800 MENU"), menuOptions, 4, 0); switch (mainMenu) { case 0: @@ -579,6 +603,7 @@ void checkStatus_7800() { print_Msg(FS(FSTRING_ROM_SIZE)); print_Msg(a7800[a7800size]); println_Msg(F("K")); + println_Msg(enable_clockgen ? FS(FSTRING_CLKGEN_ON) : FS(FSTRING_CLKGEN_OFF)); display_Update(); wait(); #else @@ -605,7 +630,8 @@ void checkStatus_7800() { Serial.print(FS(FSTRING_ROM_SIZE)); Serial.print(A7800[a7800size]); Serial.println(F("K")); - Serial.println(FS(FSTRING_EMPTY)); + Serial.println(F("K")); + Serial.println(enable_clockgen ? FS(FSTRING_CLKGEN_ON) : FS(FSTRING_CLKGEN_OFF)); #endif } diff --git a/Cart_Reader/OSCR.cpp b/Cart_Reader/OSCR.cpp index 6a8a8ee0..2961b586 100644 --- a/Cart_Reader/OSCR.cpp +++ b/Cart_Reader/OSCR.cpp @@ -80,6 +80,8 @@ constexpr char PROGMEM FSTRING_CHECKSUM[] = "Checksum: "; constexpr char PROGMEM FSTRING_ROM_SIZE[] = "ROM Size: "; constexpr char PROGMEM FSTRING_REVISION[] = "Revision: "; constexpr char PROGMEM FSTRING_SERIAL[] = "Serial: "; +constexpr char PROGMEM FSTRING_CLKGEN_ON[] = "Enable Clock Gen"; +constexpr char PROGMEM FSTRING_CLKGEN_OFF[] = "Disable Clock Gen"; /*==== /CONSTANTS =================================================*/ diff --git a/Cart_Reader/OSCR.h b/Cart_Reader/OSCR.h index 7e6b87a3..efdacb4a 100644 --- a/Cart_Reader/OSCR.h +++ b/Cart_Reader/OSCR.h @@ -130,6 +130,8 @@ extern const char PROGMEM FSTRING_NAME[]; extern const char PROGMEM FSTRING_CHECKSUM[]; extern const char PROGMEM FSTRING_REVISION[]; extern const char PROGMEM FSTRING_SERIAL[]; +extern const char PROGMEM FSTRING_CLKGEN_ON[]; +extern const char PROGMEM FSTRING_CLKGEN_OFF[]; #define FS(pmem_string) (reinterpret_cast(pmem_string)) From 999c7d20f8bbdc68791b64fe81f4d6fb1c0d6cca Mon Sep 17 00:00:00 2001 From: bootsector Date: Thu, 25 Dec 2025 05:06:23 -0500 Subject: [PATCH 2/4] Make settings displaying optional when calling setup_7800() --- Cart_Reader/7800.ino | 11 +++++++---- Cart_Reader/Cart_Reader.ino | 2 +- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/Cart_Reader/7800.ino b/Cart_Reader/7800.ino index f039b980..bc5fef70 100644 --- a/Cart_Reader/7800.ino +++ b/Cart_Reader/7800.ino @@ -87,7 +87,7 @@ static const char* const menuOptions7800[] PROGMEM = { FSTRING_SELECT_CART, FSTR // Clock Gen Menu static const char* const menuClockGen7800[] PROGMEM = { FSTRING_CLKGEN_OFF, FSTRING_CLKGEN_ON }; -void setup_7800() { +void setup_7800(bool display_status) { // Request 5V setVoltage(VOLTS_SET_5V); @@ -147,7 +147,10 @@ void setup_7800() { PORTH |= (1 << 1); } - checkStatus_7800(); + if (display_status) { + checkStatus_7800(); + } + strcpy(romName, "ATARI"); mode = CORE_7800; @@ -172,7 +175,7 @@ void a7800Menu() { break; } - setup_7800(); + setup_7800(true); #endif convertPgm(menuOptions7800, 4); @@ -182,7 +185,7 @@ void a7800Menu() { case 0: // Select Cart setCart_7800(); - setup_7800(); + setup_7800(true); break; case 1: diff --git a/Cart_Reader/Cart_Reader.ino b/Cart_Reader/Cart_Reader.ino index 619126ed..17857444 100644 --- a/Cart_Reader/Cart_Reader.ino +++ b/Cart_Reader/Cart_Reader.ino @@ -1455,7 +1455,7 @@ void mainMenu() { #ifdef ENABLE_7800 case SYSTEM_MENU_7800: - setup_7800(); + setup_7800(false); return a7800Menu(); break; #endif From bd7ba390a417de953228b950287a172f8d5347a2 Mon Sep 17 00:00:00 2001 From: bootsector Date: Thu, 25 Dec 2025 06:12:27 -0500 Subject: [PATCH 3/4] 7800.ino - Put the clock gen in HI-Z mode when disabled and present --- Cart_Reader/7800.ino | 31 +++++++++++++++++++------------ 1 file changed, 19 insertions(+), 12 deletions(-) diff --git a/Cart_Reader/7800.ino b/Cart_Reader/7800.ino index bc5fef70..495a37f1 100644 --- a/Cart_Reader/7800.ino +++ b/Cart_Reader/7800.ino @@ -122,25 +122,32 @@ void setup_7800(bool display_status) { PORTL = 0xFF; // A16-A23 PORTJ |= (1 << 0); // TIME(PJ0) - if (enable_clockgen) { - // Adafruit Clock Generator +#ifdef ENABLE_CLOCKGEN + // Adafruit Clock Generator - initializeClockOffset(); + initializeClockOffset(); - if (!i2c_found) { - display_Clear(); - print_FatalError(F("Clock Generator not found")); - } + if (!i2c_found) { + display_Clear(); + print_FatalError(F("Clock Generator not found")); + } - // Set Eeprom clock to 1Mhz - clockgen.set_freq(200000000ULL, SI5351_CLK1); + // Set Eeprom clock to 1Mhz + clockgen.set_freq(200000000ULL, SI5351_CLK1); + if (enable_clockgen) { // Start outputting Eeprom clock clockgen.output_enable(SI5351_CLK1, 1); // Eeprom clock - - // Wait for clock generator - clockgen.update_status(); } else { + clockgen.output_enable(SI5351_CLK1, 0); // SI5351_CLK_DISABLE = 0 + clockgen.set_clock_disable(SI5351_CLK1, 2); // SI5351_CLK_DISABLE_HI_Z = 2 + } + + // Wait for clock generator + clockgen.update_status(); +#endif + + if (!enable_clockgen) { // Set CLK(PH1) to Output DDRH |= (1 << 1); // Output a high signal CLK(PH1) From e9b74878cad9e849add565298edbf6cfd9272733 Mon Sep 17 00:00:00 2001 From: bootsector Date: Thu, 25 Dec 2025 06:37:44 -0500 Subject: [PATCH 4/4] 7800.ino - Show clock gen enable/disable menu only once --- Cart_Reader/7800.ino | 31 ++++++++++++++++++------------- 1 file changed, 18 insertions(+), 13 deletions(-) diff --git a/Cart_Reader/7800.ino b/Cart_Reader/7800.ino index 495a37f1..428974ba 100644 --- a/Cart_Reader/7800.ino +++ b/Cart_Reader/7800.ino @@ -78,6 +78,7 @@ byte a7800size; // 08 ROM SIZE bool enable_clockgen = false; +bool clockgen_selected = false; //****************************************** // Menu @@ -167,22 +168,26 @@ void a7800Menu() { uint8_t mainMenu; #ifdef ENABLE_CLOCKGEN - convertPgm(menuClockGen7800, 2); - mainMenu = question_box(F("ATARI 7800 MENU"), menuOptions, 2, 0); + if (!clockgen_selected) { + convertPgm(menuClockGen7800, 2); + mainMenu = question_box(F("ATARI 7800 MENU"), menuOptions, 2, 0); + + switch (mainMenu) { + case 0: + // Disable Clock Gen + enable_clockgen = false; + break; + + case 1: + // Enable Clock Gen + enable_clockgen = true; + break; + } - switch (mainMenu) { - case 0: - // Disable Clock Gen - enable_clockgen = false; - break; + setup_7800(true); - case 1: - // Enable Clock Gen - enable_clockgen = true; - break; + clockgen_selected = true; } - - setup_7800(true); #endif convertPgm(menuOptions7800, 4);