Propeller Manual

Table Of Contents
2: Spin Language Reference – _CLKFREQ
_CLKFREQ
Constant: Pre-defined, one-time settable constant for specifying the System Clock
frequency.
CON
_CLKFREQ = Expression
Expression is an integer expression that indicates the System Clock frequency upon
application start-up.
Explanation
_CLKFREQ specifies the System Clock frequency for start-up. It is a pre-defined constant
symbol whose value is determined by the top object file of an application.
_CLKFREQ is either
set directly by the application itself, or is set indirectly as the result of the
_CLKMODE and
_XINFREQ settings.
The top object file in an application (the one where compilation starts from) can specify a
setting for
_CLKFREQ in its CON block. This defines the initial System Clock frequency for the
application and is the frequency that the System Clock will switch to as soon as the
application is booted up and execution begins.
The application can specify either
_CLKFREQ or _XINFREQ in the CON block; they are mutually
exclusive and the non-specified one is automatically calculated and set as a result of
specifying the other.
The following examples assume that they are contained within the top object file. Any
_CLKFREQ settings in child objects are simply ignored by the compiler.
For example:
CON
_CLKMODE = XTAL1 + PLL8X
_CLKFREQ = 32_000_000
The first declaration in the above CON block sets the clock mode for an external low-speed
crystal and a Clock PLL multiplier of 8. The second declaration sets the System Clock
frequency to 32 MHz, which means the external crystal’s frequency must be 4 MHz because
4 MHz * 8 = 32 MHz. The
_XINFREQ value is automatically set to 4 MHz because of these
declarations.
Propeller Manual v1.1 · Page 65