1 MHz clock for the MOS 6581 using Arduino or ATTiny


I’m working on a project using the MOS 6581 synthesizer. It needs a 1 MHz clock signal. I do not have a crystal oscillator so instead I’m using the Timer 0 on an Arduino using the following code:

// Initialise Timer 0 OC0A to 1MHz on Pin 6. TIMSK0 = 0; TCNT0 = 0; // Reset timer OCR0A = 0; // Invert clock after this many clock cycles + 1 TCCR0A = 0x42; // Initialise Timer 1 TCCR0B = 0x02;

The code is taken from a project by a fellow called Alexis Kotlowy. On my 8Mhz Arduino Pro Mini however, the frequency on Pin 6 becomes only 500Khz.

Any help to double the output frequency are welcome.

Better still would be if I could use one of my ATYiny 13s to work as the clock. The code above does not compile for the ATTiny13 :-( I’m usually using the TinyCore with the Arduino IDE to develop for ATTiny13.

(I’m not really into assembler language so I’m not sure what I’m doing here. )

Many thanks in advance!