CC26xx Driver Library
[osc] Oscillator

Functions

static void OSCXHfPowerModeSet (uint32_t ui32Mode)
 Set Power Mode for High Frequency XTAL Oscillator. More...
 
static void OSCClockLossEventEnable (void)
 Enables OSC clock loss event detection. More...
 
static void OSCClockLossEventDisable (void)
 Disables OSC clock loss event detection. More...
 
void OSCClockSourceSet (uint32_t ui32SrcClk, uint32_t ui32Osc)
 Configure the oscillator input to the a source clock. More...
 
uint32_t OSCClockSourceGet (uint32_t ui32SrcClk)
 Get the source clock settings. More...
 
static bool OSCHfSourceReady (void)
 Check if the HF clock source is ready to be switched. More...
 
static void OSCHfSourceSwitch (void)
 Switch the high frequency clock. More...
 
uint32_t OSCHF_GetStartupTime (uint32_t timeUntilWakeupInMs)
 Returns maximum startup time (in microseconds) of XOSC_HF. More...
 
void OSCHF_TurnOnXosc (void)
 Turns on XOSC_HF (but without switching to XOSC_HF). More...
 
bool OSCHF_AttemptToSwitchToXosc (void)
 Switch to XOSC_HF if XOSC_HF is ready. More...
 
void OSCHF_SwitchToRcOscTurnOffXosc (void)
 Switch to RCOSC_HF and turn off XOSC_HF. More...
 
uint32_t OSCHF_DebugGetCrystalAmplitude (void)
 Get crystal amplitude (assuming crystal is running). More...
 
uint32_t OSCHF_DebugGetExpectedAverageCrystalAmplitude (void)
 Get the expected average crystal amplitude. More...
 
int32_t OSC_HPOSCRelativeFrequencyOffsetGet (int32_t tempDegC)
 Calculate the temperature dependent relative frequency offset of HPOSC. More...
 
int16_t OSC_HPOSCRelativeFrequencyOffsetToRFCoreFormatConvert (int32_t HPOSC_RelFreqOffset)
 Converts the relative frequency offset of HPOSC to the RF Core parameter format. More...
 

Detailed Description

Function Documentation

int32_t OSC_HPOSCRelativeFrequencyOffsetGet ( int32_t  tempDegC)

Calculate the temperature dependent relative frequency offset of HPOSC.

The HPOSC (High Precision Oscillator) frequency will vary slightly with chip temperature. The frequency offset from the nominal value can be predicted based on second order linear interpolation using coefficients measured in chip production and stored as factory configuration parameters.

This function calculates the relative frequency offset, defined as:

    F_HPOSC = F_nom * (1 + d/(2^22))

where

  • F_HPOSC is the current HPOSC frequency.
  • F_nom is the nominal oscillator frequency, assumed to be 48.000 MHz.
  • d is the relative frequency offset (the value returned).

By knowing the relative frequency offset it is then possible to compensate any timing related values accordingly.

Parameters
tempDegCis the chip temperature in degrees Celsius. Use the function AONBatMonTemperatureGetDegC() to get current chip temperature.
Returns
Returns the relative frequency offset parameter d.
See also
OSC_HPOSCRelativeFrequencyOffsetToRFCoreFormatConvert(), AONBatMonTemperatureGetDegC()
312 {
313  // Estimate HPOSC frequency, using temperature and curve fitting parameters
314  uint32_t fitParams = HWREG(FCFG1_BASE + FCFG1_O_FREQ_OFFSET);
315  // Extract the P0,P1,P2 params, and sign extend them via shifting up/down
316  int32_t paramP0 = ((((int32_t) fitParams) << (32 - FCFG1_FREQ_OFFSET_HPOSC_COMP_P0_W - FCFG1_FREQ_OFFSET_HPOSC_COMP_P0_S))
318  int32_t paramP1 = ((((int32_t) fitParams) << (32 - FCFG1_FREQ_OFFSET_HPOSC_COMP_P1_W - FCFG1_FREQ_OFFSET_HPOSC_COMP_P1_S))
320  int32_t paramP2 = ((((int32_t) fitParams) << (32 - FCFG1_FREQ_OFFSET_HPOSC_COMP_P2_W - FCFG1_FREQ_OFFSET_HPOSC_COMP_P2_S))
322  int32_t paramP3 = ((((int32_t) HWREG(FCFG1_BASE + FCFG1_O_MISC_CONF_2))
325 
326  // Now we can find the HPOSC freq offset, given as a signed variable d, expressed by:
327  //
328  // F_HPOSC = F_nom * (1 + d/(2^22)) , where: F_HPOSC = HPOSC frequency
329  // F_nom = nominal clock source frequency (e.g. 48.000 MHz)
330  // d = describes relative freq offset
331 
332  // We can estimate the d variable, using temperature compensation parameters:
333  //
334  // d = P0 + P1*(t - T0) + P2*(t - T0)^2 + P3*(t - T0)^3, where: P0,P1,P2,P3 are curve fitting parameters from FCFG1
335  // t = current temperature (from temp sensor) in deg C
336  // T0 = 27 deg C (fixed temperature constant)
337  int32_t tempDelta = (tempDegC - 27);
338  int32_t tempDeltaX2 = tempDelta * tempDelta;
339  int32_t d = paramP0 + ((tempDelta*paramP1)>>3) + ((tempDeltaX2*paramP2)>>10) + ((tempDeltaX2*tempDelta*paramP3)>>18);
340 
341  return ( d );
342 }
int16_t OSC_HPOSCRelativeFrequencyOffsetToRFCoreFormatConvert ( int32_t  HPOSC_RelFreqOffset)

Converts the relative frequency offset of HPOSC to the RF Core parameter format.

The HPOSC (High Precision Oscillator) clock is used by the RF Core. To compensate for a frequency offset in the frequency of the clock source, a frequency offset parameter can be provided as part of the radio configuration override setting list to enable compensation of the RF synthesizer frequency, symbol timing, and radio timer to still achieve correct frequencies.

The RF Core takes a relative frequency offset parameter defined differently compared to the relative frequency offset parameter returned from function OSC_HPOSCRelativeFrequencyOffsetGet() and thus needs to be converted:

    F_nom = F_HPOSC * (1 + RfCoreRelFreqOffset/(2^22))

where

  • F_nom is the nominal oscillator frequency, assumed to be 48.000 MHz.
  • F_HPOSC is the current HPOSC frequency.
  • RfCoreRelFreqOffset is the relative frequency offset in the "RF Core" format (the value returned).
Returns
Returns the relative frequency offset in RF Core format.
See also
OSC_HPOSCRelativeFrequencyOffsetGet()
351 {
352  // The input argument, hereby referred to simply as "d", describes the frequency offset
353  // of the HPOSC relative to the nominal frequency in this way:
354  //
355  // F_HPOSC = F_nom * (1 + d/(2^22))
356  //
357  // But for use by the radio, to compensate the frequency error, we need to find the
358  // frequency offset "rfcFreqOffset" defined in the following format:
359  //
360  // F_nom = F_HPOSC * (1 + rfCoreFreqOffset/(2^22))
361  //
362  // To derive "rfCoreFreqOffset" from "d" we combine the two above equations and get:
363  //
364  // (1 + rfCoreFreqOffset/(2^22)) = (1 + d/(2^22))^-1
365  //
366  // Which can be rewritten into:
367  //
368  // rfCoreFreqOffset = -d*(2^22) / ((2^22) + d)
369  //
370  // = -d * [ 1 / (1 + d/(2^22)) ]
371  //
372  // To avoid doing a 64-bit division due to the (1 + d/(2^22))^-1 expression,
373  // we can use Taylor series (Maclaurin series) to approximate it:
374  //
375  // 1 / (1 - x) ~= 1 + x + x^2 + x^3 + x^4 + ... etc (Maclaurin series)
376  //
377  // In our case, we have x = - d/(2^22), and we only include up to the first
378  // order term of the series, as the second order term ((d^2)/(2^44)) is very small:
379  //
380  // freqError ~= -d + d^2/(2^22) (+ small approximation error)
381  //
382  // The approximation error is negligible for our use.
383 
384  int32_t rfCoreFreqOffset = -HPOSC_RelFreqOffset + (( HPOSC_RelFreqOffset * HPOSC_RelFreqOffset ) >> 22 );
385 
386  return ( rfCoreFreqOffset );
387 }
static void OSCClockLossEventDisable ( void  )
inlinestatic

Disables OSC clock loss event detection.

Disabling the OSC clock loss event does also clear the clock loss event flag.

Note
OSC clock loss event must be disabled before SCLK_LF clock source is changed (by calling OSCClockSourceSet()) and remain disabled until the change is confirmed (by calling OSCClockSourceGet()).
Returns
None
See also
OSCClockLossEventEnable()
201 {
205 }
void DDI16BitfieldWrite(uint32_t ui32Base, uint32_t ui32Reg, uint32_t ui32Mask, uint32_t ui32Shift, uint16_t ui32Data)
Write a bitfield via the DDI using 16-bit maskable write.
Definition: ddi.c:117

Here is the call graph for this function:

static void OSCClockLossEventEnable ( void  )
inlinestatic

Enables OSC clock loss event detection.

Enables the clock loss event flag to be raised if a clock loss is detected.

Note
OSC clock loss event must be disabled before SCLK_LF clock source is changed (by calling OSCClockSourceSet()) and remain disabled until the change is confirmed (by calling OSCClockSourceGet()).
Returns
None
See also
OSCClockLossEventDisable()
178 {
182 }
void DDI16BitfieldWrite(uint32_t ui32Base, uint32_t ui32Reg, uint32_t ui32Mask, uint32_t ui32Shift, uint16_t ui32Data)
Write a bitfield via the DDI using 16-bit maskable write.
Definition: ddi.c:117

Here is the call graph for this function:

uint32_t OSCClockSourceGet ( uint32_t  ui32SrcClk)

Get the source clock settings.

Use this function to get the oscillator source for one of the system source clocks.

Parameters
ui32SrcClkis the source clock to check.
Returns
Returns the type of oscillator that drives the clock source.
See also
OSCClockSourceSet(), OSCHfSourceSwitch()

Referenced by OSCHF_AttemptToSwitchToXosc(), OSCHF_SwitchToRcOscTurnOffXosc(), and SetupAfterColdResetWakeupFromShutDownCfg3().

148 {
149  uint32_t ui32ClockSource;
150 
151  // Check the arguments.
152  ASSERT((ui32SrcClk & OSC_SRC_CLK_LF) ||
153  (ui32SrcClk & OSC_SRC_CLK_HF));
154 
155  // Return the source for the selected clock.
156  if(ui32SrcClk == OSC_SRC_CLK_LF)
157  {
161  }
162  else
163  {
167  }
168  return (ui32ClockSource);
169 }
#define OSC_SRC_CLK_HF
Definition: osc.h:112
#define OSC_SRC_CLK_LF
Definition: osc.h:114
uint16_t DDI16BitfieldRead(uint32_t ui32Base, uint32_t ui32Reg, uint32_t ui32Mask, uint32_t ui32Shift)
Read a bitfield via the DDI using 16-bit read.
Definition: ddi.c:185
#define ASSERT(expr)
Definition: debug.h:74

Here is the call graph for this function:

void OSCClockSourceSet ( uint32_t  ui32SrcClk,
uint32_t  ui32Osc 
)

Configure the oscillator input to the a source clock.

Use this function to set the oscillator source for one or more of the system source clocks.

When selecting the high frequency clock source, this function will not do the actual switch. Enabling the high frequency XTAL can take several hundred micro seconds, so the actual switch is split into a separate function, leaving System CPU free to perform other tasks as the XTAL starts up.

Note
The High Frequency (OSC_SRC_CLK_HF) and Medium Frequency (OSC_SRC_CLK_MF) can only be derived from the high frequency oscillator. The Low Frequency source clock (OSC_SRC_CLK_LF) can be derived from all 4 oscillators.
If enabling OSC_XOSC_LF it is not safe to go to powerdown/shutdown until the LF clock is running which can be checked using OSCClockSourceGet().
Clock loss reset generation must be disabled before SCLK_LF (OSC_SRC_CLK_LF) clock source is changed and remain disabled until the change is confirmed.
Parameters
ui32SrcClkis the source clocks to configure.
ui32Oscis the oscillator that drives the source clock.
See also
OSCClockSourceGet()
Returns
None

Referenced by OSCHF_SwitchToRcOscTurnOffXosc(), OSCHF_TurnOnXosc(), and SetupAfterColdResetWakeupFromShutDownCfg3().

101 {
102  // Check the arguments.
103  ASSERT((ui32SrcClk & OSC_SRC_CLK_LF) ||
104  (ui32SrcClk & OSC_SRC_CLK_MF) ||
105  (ui32SrcClk & OSC_SRC_CLK_HF));
106  ASSERT((ui32Osc == OSC_RCOSC_HF) ||
107  (ui32Osc == OSC_RCOSC_LF) ||
108  (ui32Osc == OSC_XOSC_HF) ||
109  (ui32Osc == OSC_XOSC_LF));
110 
111  // Request the high frequency source clock (using 24 MHz XTAL)
112  if(ui32SrcClk & OSC_SRC_CLK_HF)
113  {
114  // Enable the HF XTAL as HF clock source
118  ui32Osc);
119  }
120 
121  // Configure the medium frequency source clock
122  if(ui32SrcClk & OSC_SRC_CLK_MF)
123  {
127  ui32Osc);
128  }
129 
130  // Configure the low frequency source clock.
131  if(ui32SrcClk & OSC_SRC_CLK_LF)
132  {
133  // Change the clock source.
137  ui32Osc);
138  }
139 }
#define OSC_SRC_CLK_MF
Definition: osc.h:113
void DDI16BitfieldWrite(uint32_t ui32Base, uint32_t ui32Reg, uint32_t ui32Mask, uint32_t ui32Shift, uint16_t ui32Data)
Write a bitfield via the DDI using 16-bit maskable write.
Definition: ddi.c:117
#define OSC_SRC_CLK_HF
Definition: osc.h:112
#define OSC_RCOSC_HF
Definition: osc.h:116
#define OSC_XOSC_HF
Definition: osc.h:117
#define OSC_SRC_CLK_LF
Definition: osc.h:114
#define ASSERT(expr)
Definition: debug.h:74
#define OSC_RCOSC_LF
Definition: osc.h:118
#define OSC_XOSC_LF
Definition: osc.h:119

Here is the call graph for this function:

bool OSCHF_AttemptToSwitchToXosc ( void  )

Switch to XOSC_HF if XOSC_HF is ready.

This is a non-blocking function checking if the XOSC_HF is ready and performs the switching if ready. The function is somewhat blocking in the case where switching is performed.

Returns
Returns status of the XOSC_HF switching:
  • true : Switching to XOSC_HF has occurred.
  • false : Switching has not occurred.
244 {
245  uint32_t startupTimeInUs;
246  uint32_t prevLimmit25InUs;
247 
248 #if ( defined( ROM_OSCClockSourceGet ))
249  if ( ROM_OSCClockSourceGet( OSC_SRC_CLK_HF ) == OSC_XOSC_HF )
250 #else
252 #endif
253  {
254  // Already on XOSC - nothing to do
255  return ( 1 );
256  }
257  if ( OSCHfSourceReady()) {
259 
260  // Store startup time, but limit to 25 percent reduction each time.
263  prevLimmit25InUs = oscHfGlobals.previousStartupTimeInUs;
264  prevLimmit25InUs -= ( prevLimmit25InUs >> 2 ); // 25 percent margin
265  oscHfGlobals.previousStartupTimeInUs = startupTimeInUs;
266  if ( prevLimmit25InUs > startupTimeInUs ) {
267  oscHfGlobals.previousStartupTimeInUs = prevLimmit25InUs;
268  }
269  return ( 1 );
270  }
271  return ( 0 );
272 }
static void OSCHfSourceSwitch(void)
Switch the high frequency clock.
Definition: osc.h:314
uint32_t timeXoscStable_CV
Definition: osc.c:88
uint32_t OSCClockSourceGet(uint32_t ui32SrcClk)
Get the source clock settings.
Definition: osc.c:147
#define OSC_SRC_CLK_HF
Definition: osc.h:112
static bool OSCHfSourceReady(void)
Check if the HF clock source is ready to be switched.
Definition: osc.h:286
#define OSC_XOSC_HF
Definition: osc.h:117
uint32_t previousStartupTimeInUs
Definition: osc.c:85
static OscHfGlobals_t oscHfGlobals
Definition: osc.c:92
uint32_t timeXoscOn_CV
Definition: osc.c:87
#define RTC_CV_TO_US(x)
Definition: osc.c:82
uint32_t AONRTCCurrentCompareValueGet(void)
Get the current value of the RTC counter in a format that matches RTC compare values.
Definition: aon_rtc.c:62

Here is the call graph for this function:

uint32_t OSCHF_DebugGetCrystalAmplitude ( void  )

Get crystal amplitude (assuming crystal is running).

Note
This is a debug function only. It is hence not recommended to call this function in normal operation.

This function uses an on-chip ADC and peak detector for reading the crystal amplitude. The measurement time is set to 4 milliseconds and this function does not return before the measurement is done.

Expected value is OSCHF_DebugGetExpectedAverageCrystalAmplitude +/- 50 millivolt.

Returns
Returns crystal amplitude in millivolt.
See also
OSCHF_DebugGetExpectedAverageCrystalAmplitude()
396 {
397  uint32_t oscCfgRegCopy ;
398  uint32_t startTime ;
399  uint32_t deltaTime ;
400  uint32_t ampValue ;
401 
402  // The specified method is as follows:
403  // 1. Set minimum interval between oscillator amplitude calibrations.
404  // (Done by setting PER_M=0 and PER_E=1)
405  // 2. Wait approximately 4 milliseconds in order to measure over a
406  // moderately large number of calibrations.
407  // 3. Read out the crystal amplitude value from the peek detector.
408  // 4. Restore original oscillator amplitude calibrations interval.
409  // 5. Return crystal amplitude value converted to millivolt.
410  oscCfgRegCopy = HWREG( AON_WUC_BASE + AON_WUC_O_OSCCFG );
412  startTime = AONRTCCurrentCompareValueGet();
413  do {
414  deltaTime = AONRTCCurrentCompareValueGet() - startTime;
415  } while ( deltaTime < ((uint32_t)( 0.004 * FACTOR_SEC_TO_COMP_VAL_FORMAT )));
416  ampValue = ( HWREG( AUX_DDI0_OSC_BASE + DDI_0_OSC_O_STAT1 ) &
419  HWREG( AON_WUC_BASE + AON_WUC_O_OSCCFG ) = oscCfgRegCopy;
420 
421  return ( ampValue * 15 );
422 }
#define FACTOR_SEC_TO_COMP_VAL_FORMAT
Definition: aon_rtc.h:151
uint32_t AONRTCCurrentCompareValueGet(void)
Get the current value of the RTC counter in a format that matches RTC compare values.
Definition: aon_rtc.c:62

Here is the call graph for this function:

uint32_t OSCHF_DebugGetExpectedAverageCrystalAmplitude ( void  )

Get the expected average crystal amplitude.

Note
This is a debug function only. It is hence not recommended to call this function in normal operation.

This function read the configured high and low thresholds and returns the mean value converted to millivolt.

Returns
Returns expected average crystal amplitude in millivolt.
See also
OSCHF_DebugGetCrystalAmplitude()
431 {
432  uint32_t ampCompTh1 ;
433  uint32_t highThreshold ;
434  uint32_t lowThreshold ;
435 
436  ampCompTh1 = HWREG( AUX_DDI0_OSC_BASE + DDI_0_OSC_O_AMPCOMPTH1 );
437  highThreshold = ( ampCompTh1 & DDI_0_OSC_AMPCOMPTH1_HPMRAMP3_HTH_M ) >>
439  lowThreshold = ( ampCompTh1 & DDI_0_OSC_AMPCOMPTH1_HPMRAMP3_LTH_M ) >>
441 
442  return ((( highThreshold + lowThreshold ) * 15 ) >> 1 );
443 }
uint32_t OSCHF_GetStartupTime ( uint32_t  timeUntilWakeupInMs)

Returns maximum startup time (in microseconds) of XOSC_HF.

The startup time depends on several factors. This function calculates the maximum startup time based on statistical information.

Parameters
timeUntilWakeupInMsindicates how long time (milliseconds) to the startup will occur.
Returns
Time margin to use in microseconds.
178 {
179  uint32_t deltaTimeSinceXoscOnInMs ;
180  int32_t deltaTempSinceXoscOn ;
181  uint32_t newStartupTimeInUs ;
182 
183  deltaTimeSinceXoscOnInMs = RTC_CV_TO_MS( AONRTCCurrentCompareValueGet() - oscHfGlobals.timeXoscOn_CV );
184  deltaTempSinceXoscOn = AONBatMonTemperatureGetDegC() - oscHfGlobals.tempXoscOff;
185 
186  if ( deltaTempSinceXoscOn < 0 ) {
187  deltaTempSinceXoscOn = -deltaTempSinceXoscOn;
188  }
189 
190  if ( (( timeUntilWakeupInMs + deltaTimeSinceXoscOnInMs ) > 3000 ) ||
191  ( deltaTempSinceXoscOn > 5 ) ||
194  {
195  newStartupTimeInUs = 2000;
197  newStartupTimeInUs = (( HWREG( CCFG_BASE + CCFG_O_MODE_CONF_1 ) &
200  // Note: CCFG startup time is "in units of 100us" adding 25% margin results in *125
201  }
202  } else {
204  newStartupTimeInUs += ( newStartupTimeInUs >> 2 ); // Add 25 percent margin
205  if ( newStartupTimeInUs < oscHfGlobals.previousStartupTimeInUs ) {
206  newStartupTimeInUs = oscHfGlobals.previousStartupTimeInUs;
207  }
208  }
209 
210  if ( newStartupTimeInUs < 200 ) {
211  newStartupTimeInUs = 200;
212  }
213  if ( newStartupTimeInUs > 4000 ) {
214  newStartupTimeInUs = 4000;
215  }
216  return ( newStartupTimeInUs );
217 }
uint32_t timeXoscStable_CV
Definition: osc.c:88
int32_t AONBatMonTemperatureGetDegC(void)
Get the current temperature measurement as a signed value in Deg Celsius.
Definition: aon_batmon.c:60
uint32_t previousStartupTimeInUs
Definition: osc.c:85
static OscHfGlobals_t oscHfGlobals
Definition: osc.c:92
int32_t tempXoscOff
Definition: osc.c:89
uint32_t timeXoscOn_CV
Definition: osc.c:87
#define RTC_CV_TO_US(x)
Definition: osc.c:82
uint32_t AONRTCCurrentCompareValueGet(void)
Get the current value of the RTC counter in a format that matches RTC compare values.
Definition: aon_rtc.c:62
#define RTC_CV_TO_MS(x)
Definition: osc.c:81

Here is the call graph for this function:

void OSCHF_SwitchToRcOscTurnOffXosc ( void  )

Switch to RCOSC_HF and turn off XOSC_HF.

This operation takes approximately 50 microseconds (can be shorter if RCOSC_HF already was running).

Returns
None
282 {
283  // Set SCLK_HF and SCLK_MF to RCOSC_HF without checking
284  // Doing this anyway to keep HF and MF in sync
285 #if ( defined( ROM_OSCClockSourceSet ))
286  ROM_OSCClockSourceSet( OSC_SRC_CLK_HF | OSC_SRC_CLK_MF, OSC_RCOSC_HF );
287 #else
289 #endif
290 
291  // Do the switching if not already running on RCOSC_HF
292 #if ( defined( ROM_OSCClockSourceGet ))
293  if ( ROM_OSCClockSourceGet( OSC_SRC_CLK_HF ) != OSC_RCOSC_HF )
294 #else
296 #endif
297  {
299  }
300 
303 }
static void OSCHfSourceSwitch(void)
Switch the high frequency clock.
Definition: osc.h:314
#define OSC_SRC_CLK_MF
Definition: osc.h:113
uint32_t timeXoscOff_CV
Definition: osc.c:86
int32_t AONBatMonTemperatureGetDegC(void)
Get the current temperature measurement as a signed value in Deg Celsius.
Definition: aon_batmon.c:60
uint32_t OSCClockSourceGet(uint32_t ui32SrcClk)
Get the source clock settings.
Definition: osc.c:147
#define OSC_SRC_CLK_HF
Definition: osc.h:112
#define OSC_RCOSC_HF
Definition: osc.h:116
static OscHfGlobals_t oscHfGlobals
Definition: osc.c:92
int32_t tempXoscOff
Definition: osc.c:89
uint32_t AONRTCCurrentCompareValueGet(void)
Get the current value of the RTC counter in a format that matches RTC compare values.
Definition: aon_rtc.c:62
void OSCClockSourceSet(uint32_t ui32SrcClk, uint32_t ui32Osc)
Configure the oscillator input to the a source clock.
Definition: osc.c:100

Here is the call graph for this function:

void OSCHF_TurnOnXosc ( void  )

Turns on XOSC_HF (but without switching to XOSC_HF).

This function simply indicates the need for XOSC_HF to the hardware which initiates the XOSC_HF startup.

Returns
None
227 {
228 #if ( defined( ROM_OSCClockSourceSet ))
229  ROM_OSCClockSourceSet( OSC_SRC_CLK_HF | OSC_SRC_CLK_MF, OSC_XOSC_HF );
230 #else
232 #endif
234 }
#define OSC_SRC_CLK_MF
Definition: osc.h:113
#define OSC_SRC_CLK_HF
Definition: osc.h:112
#define OSC_XOSC_HF
Definition: osc.h:117
static OscHfGlobals_t oscHfGlobals
Definition: osc.c:92
uint32_t timeXoscOn_CV
Definition: osc.c:87
uint32_t AONRTCCurrentCompareValueGet(void)
Get the current value of the RTC counter in a format that matches RTC compare values.
Definition: aon_rtc.c:62
void OSCClockSourceSet(uint32_t ui32SrcClk, uint32_t ui32Osc)
Configure the oscillator input to the a source clock.
Definition: osc.c:100

Here is the call graph for this function:

static bool OSCHfSourceReady ( void  )
inlinestatic

Check if the HF clock source is ready to be switched.

If a request to switch the HF clock source has been made, this function can be used to check if the clock source is ready to be switched.

Once the HF clock source is ready the switch can be performed by calling the OSCHfSourceSwitch()

Returns
Returns status of HF clock source:
  • true : HF clock source is ready.
  • false : HF clock source is not ready.

Referenced by OSCHF_AttemptToSwitchToXosc().

287 {
288  // Return the readiness of the HF clock source
292  true : false;
293 }
uint16_t DDI16BitfieldRead(uint32_t ui32Base, uint32_t ui32Reg, uint32_t ui32Mask, uint32_t ui32Shift)
Read a bitfield via the DDI using 16-bit read.
Definition: ddi.c:185

Here is the call graph for this function:

static void OSCHfSourceSwitch ( void  )
inlinestatic

Switch the high frequency clock.

When switching the HF clock source the clock period might be prolonged leaving the clock 'stuck-at' high or low for a few cycles. To ensure that this does not coincide with a read access to the Flash potentially freezing the device, the HF clock source switch must be executed from ROM.

Note
This function will not return until the clock source has been switched. It is left to the programmer to ensure, that there is a pending request for a HF clock source switch before this function is called.
Returns
None
See also
OSCClockSourceSet()

Referenced by OSCHF_AttemptToSwitchToXosc(), and OSCHF_SwitchToRcOscTurnOffXosc().

315 {
316  // Switch the HF clock source
318 }
#define HapiHFSourceSafeSwitch()
Definition: rom.h:157
static void OSCXHfPowerModeSet ( uint32_t  ui32Mode)
inlinestatic

Set Power Mode for High Frequency XTAL Oscillator.

Parameters
ui32Modeis the power mode for the HF XTAL.
Returns
None
151 {
152  // Check the arguments.
153  ASSERT((ui32Mode == LOW_POWER_XOSC) ||
154  (ui32Mode == HIGH_POWER_XOSC));
155 
156  // Change the power mode.
158  ui32Mode);
159 }
#define LOW_POWER_XOSC
Definition: osc.h:104
void DDI16BitWrite(uint32_t ui32Base, uint32_t ui32Reg, uint32_t ui32Mask, uint32_t ui32WrData)
Write a single bit using a 16-bit maskable write.
Definition: ddi.c:83
#define HIGH_POWER_XOSC
Definition: osc.h:105
#define ASSERT(expr)
Definition: debug.h:74

Here is the call graph for this function:

Macro Definition Documentation

#define HIGH_POWER_XOSC   0

Referenced by OSCXHfPowerModeSet().

#define LOW_POWER_XOSC   1

Referenced by OSCXHfPowerModeSet().

#define OSC_RCOSC_HF   0x00000000
#define OSC_RCOSC_LF   0x00000002
#define OSC_SRC_CLK_LF   0x00000004
#define OSC_SRC_CLK_MF   0x00000002
#define OSC_XOSC_LF   0x00000003
#define SCLK_HF_RCOSC_HF   0
#define SCLK_HF_XOSC_HF   1
#define SCLK_LF_FROM_RCOSC_HF   0
#define SCLK_LF_FROM_RCOSC_LF   2
#define SCLK_LF_FROM_XOSC_HF   1
#define SCLK_LF_FROM_XOSC_LF   3
#define SCLK_MF_RCOSC_HF   0
#define SCLK_MF_XOSC_HF   1