Sample Code For Initial Configuration Of Clock Calibration Counter With Ilo0 And Eco - Infineon XMC7000 Manual

Hide thumbs Also See for XMC7000:
Table of Contents

Advertisement

Clock configuration setup in XMC7000 MCU family
Supplementary information
Table 3
Functions for clock calibration counter with ILO0 and ECO
Functions
GetILOClockFreq()
Cy_SysClk_StartClk
MeasurementCounters
(clk1, count1, clk2)
Cy_SysClk_ClkMeasurement
CountersDone()
Cy_SysClk_ClkMeasurement
CountersGetFreq
(MesauredFreq, refClkFreq)
6.2.3.1
Sample code for initial configuration of clock calibration counter with
ILO0 and ECO
The following is the sample code:
/* Scenario: ILO frequency may be drifting. Measure the ILO frequency
using
reference. */
#define
EC0_FREQ
#define
ILO_NOMINAL
/* Start the ILO clock measurement using the ECO */
(void)Cy_SysClk_StartClkMeasurementCounters(CY_SYSCLK_MEAS_CLK_ILO,
/* Counter 1 clock
/* Counter 1 period = 128 */
/* Counter 2 clock
/* Wait for counter 1 to reach 0 */
while(!Cy_SysClk_ClkMeasurementCountersDone()){}
/* Measure clock 1 with the ECO clock cycles (counter 2) */
uint32_t measuredFreq = Cy_SysClk_ClkMeasurementCountersGetFreq(false,
ECO_FREQ);
if(measuredFreq != ILO_NOMINAL)
{
/* Take appropriate action such as trimming the ILO or changing the
LFCLK source */
}
Application note
Description
Get the ILO 0 Frequency
Set and start calibration
Clk1: Reference clock
Count1: Measurement period
Clk2: Measurement clock
Check if counter measurement is
done
Get the measurement clock
frequency
MesauredFreq: Stored measurement
clock frequency
refClkFreq: Reference clock
frequency
the clock measurement counters, with the IMO as the
16000000UL
32768UL
= ILO */
= IMO */
Value
[Set the counter]
clk1 = CY_SYSCLK_MEAS_CLK_ECO =
0x101ul
count1 = counter1
clk2 = clockMeasuredInfo[].name
MesauredFreq =
clockMeasuredInfo[].measuredFreq
refClkFreq = CLK_FREQ_ECO
/* 16 MHz ECO */
/* 32.768 kHz ILO */
0x7FUL,
CY_SYSCLK_MEAS_CLK_ECO);
36
002-34253 Rev. *C
2023-11-08

Advertisement

Table of Contents
loading

Table of Contents