18.6. Functional Description
18.6.1. Principle of Operation
During a period of
REFNUM/�
CLK_REF
, the FREQM is counting the number of periods of the clock to be
measured,
VALUE
. Here,
REFNUM
is the Number of Reference Clock Cycles selected in the Configuration
A register (CFGA.REFNUM),
VALUE
is the Measurement result stored to the Value register
(VALUE.VALUE), and
�
CLK_REF
is the frequency of the reference clock.
The frequency of the measured clock,
�
CLK_MSR
, is calculated by
�
CLK_MSR
= VALUE
REFNUM �
CLK_REF
18.6.2. Basic Operation
18.6.2.1. Initialization
Before enabling FREQM, the device and peripheral must be configured:
•
Each of the generic clocks (GCLK_FREQM_REF and GCLK_FREQM_MSR) should be configured
and enabled. Note that the reference clock should be slower than the measurement clock.
•
The Number of Reference Clock Cycles value in the Configuration A register (
must be written to a value greater than 0x00.
The following register is enable-protected, meaning that it can only be written when the FREQM is
disabled (CTRLA.ENABLE is zero):
•
Configuration A register (CFGA)
Enable-protection is denoted by the "Enable-Protected" property in the register description.
Related Links
GCLK - Generic Clock Controller
on page 121
18.6.2.2. Enabling, Disabling and Resetting
The FREQM is enabled by writing a '1' to the Enable bit in the Control A register (
.ENABLE). The
peripheral is disabled by writing CTRLA.ENABLE=0.
The FREQM is reset by writing a '1' to the Software Reset bit in the Control A register (CTRLA.SWRST).
All registers in the FREQM will be reset to their initial state, and the FREQM will be disabled.
18.6.2.3. Measurement
In the Configuration A register, the Number of Reference Clock Cycles field (
.REFNUM) selects the
duration of the measurement. The measurement is given in number of GCLK_FREQM_REF periods.
Note:
This field must be written before the FREQM is enabled.
After the FREQM is enabled, writing a '1' to the START bit in the Control B register (
.START) starts
the measurement. The BUSY bit in Status register (
.BUSY) is cleared when the measurement is
done.
There is also an interrupt request for Measurement Done: When the Measurement Done bit in Interrupt
Enable Set register (
.DONE) is '1' and a measurement is finished, the Measurement Done bit
in the Interrupt Flag Status and Clear register (
.DONE) will be set and an interrupt request is
generated.
The result of the measurement can be read from the Value register (
.VALUE). The frequency of
the measured clock GCLK_FREQM_MSR is then:
Atmel SAM L22G / L22J / L22N [DATASHEET]
Atmel-42402E-SAM L22G / L22J / L22N_Datasheet_Complete-07/2016
168