MEAM.Design - MAEVARM - System Clock


The M2 board is pre-configured with a 16.0 MHz external oscillator, and by default the system clock prescaler is set to divide by 8 (CKSEL[3:0] = "1111", SUT = "10", CKDIV8 = "0"), resulting in a 2.0 MHz system clock.


Changing the Prescaler:

To change the system clock prescaler, you can either:


1. Use the following custom function defined in m_general.h:

m_clockdivide();


2. Do this manually by first enabling changes to the prescaler by setting the entire CLKPR register to a value of "1000 0000" using the CLKPCE bitmask:

CLKPR = (1<<CLKPCE);

and then immediately setting the prescale divide-by as

CLKPR = n;

where n corresponds to division by 2^n, up to 256 (n=8).


Important Notes

There are certain functions (m_wait(), _delay_ms(), etc.) which use the value stored in the configuration options for the project (select Configuration Options from the Project menu) to set time intervals. If you are using any such functions, you need to change the value to match the prescaled system clock.