1

I want to overclock my Game Boy Advance SP. It has a built-in 4 MHz crystal, and I was able to temporarily replace it with an 8 MHz crystal to see if I was able to overclock it, which I was :).

However I'm wondering if it's possible to emulate/simulate a crystal using an Arduino? Like instead of a crystal soldered to the Game Boy, two output pins from the Arduino? If not, is there a such thing as a variable oscillator? Like a crystal with a potentiometer to change the frequency when the potentiometer is adjusted?

Peter Mortensen
  • 435
  • 3
  • 12
Leo Takacs
  • 53
  • 1
  • 1
  • 5

3 Answers3

2

You want to use the Uno? You can set up a timer to output varying frequencies and output them on a pin. I have a page about timers which might help. The fastest you can get with a 16 MHz processor is 8 MHz output however you can get other frequencies by changing the timer parameters.

The ATtiny85 can output higher frequencies if you use the PLL clock option, I think you can then adjust the resulting frequency.

If not, is there a such thing as a variable oscillator?

Adafruit make a Clock Generator Breakout Board - 8KHz to 160MHz. You connect that via I2C to your Arduino and then program assorted frequencies as a clock output. That uses the Si5351A clock generator chip.


Example code to output 8 MHz on a Uno or Mega2560:

#ifdef __AVR_ATmega2560__
  const byte CLOCKOUT = 11;  // Mega 2560
#else
  const byte CLOCKOUT = 9;   // Uno, Duemilanove, etc.
#endif

void setup ()
  {
  // set up 8 MHz timer on CLOCKOUT (OC1A)
  pinMode (CLOCKOUT, OUTPUT); 
  // set up Timer 1
  TCCR1A = bit (COM1A0);  // toggle OC1A on Compare Match
  TCCR1B = bit (WGM12) | bit (CS10);   // CTC, no prescaling
  OCR1A =  0;       // output every cycle
  }  // end of setup

void loop ()
  {
  // whatever 
  }  // end of loop

To output 4 MHz change OCR1A to 1 rather than 0.

Nick Gammon
  • 38,901
  • 13
  • 69
  • 125
2

A crystal oscillator connection to a microcontroller typically consists of two pins - an output "driving" pin, and an input "amplifying" pin. The crystal sits between the two pins (basically between the input and the output of the amplifier) and the amplifier oscillates at the frequency of the crystal.

In general you can bypass the crystal itself and just provide a clock signal on the input pin (often labelled OSC1 or OSCI) and ignore the output pin since it isn't needed to drive a crystal.

Some microcontrollers provide a special "EC" mode (External Clock) which disables the amplifier and just expects a clock signal.

Majenko
  • 105,851
  • 5
  • 82
  • 139
0

Using the Arduino platform as a signal generator (oscillator) results in too high a granularity factor. Software that has been suggested can only change between 8 and 4 MHz but not output anything between those two frequencies.

It would be better to use some sort of DDS or Frequency Synthesizer circuit that can be adjusted incrementally with a granularity of 1 Hz or better.
My suggestion would be to use the Arduino to control a modern synthesis IC like the S15351a. This combination can output any frequency from 3KHz to 160 MHz in 1 Hz steps. The device is inexpensive and has 3 outputs which can be adjusted independently. Google "Si5351a Arduino" to find some circuit suggestions. https://www.qrp-labs.com/progrock.html

arv
  • 9
  • 1