Nano Generated 1-MHz CPU Clock?
Opened this issue · 0 comments
Mike-K8LH commented
Couldn't the Nano provide the 1-MHz CPU clock (running as a background task on the Nano)? Example code snippet;
/***************************************************************************
* output 1-MHz clock on OC2A (D11/PB3) for RC6502 SBC *
***************************************************************************/
void beginClock()
{ pinMode(11,OUTPUT); // OC2A (D11/PB3)
/* *
* TCCR2A settings for 'normal' or 'CTC' (non-PWM) mode *
* ------------------------------------------------------------ *
* COM2A1:COM2A0 '01' - Toggle OC2A on Compare Match *
* WGM22:WGM20 '010' - CTC mode (clear timer on compare match) *
* (WGM22 bit is in TCCR2B register) *
* */
TCCR2A = ((1 << WGM21) | (1 << COM2A0));
TCCR2B = (1 << CS20); // prescale = 1:1 (WGM22 = 0)
TIMSK2 = 0; // no interrupts
OCR2A = 7; // match value
} // 0/1/3/7 => 8/4/2/1 MHz
/***************************************************************************/