CC26xx Driver Library
[osc.h] 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...
 
void OSC_AdjustXoscHfCapArray (int32_t capArrDelta)
 Adjust the XOSC HF cap array relative to the factory setting. 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

void OSC_AdjustXoscHfCapArray ( int32_t  capArrDelta)

Adjust the XOSC HF cap array relative to the factory setting.

The cap array factory setting (FCFG) can be converted to a number in the range 0 - 63. Both this function and the customer configuration (CCFG) setting can apply a delta to the FCFG setting. The CCFG setting is automatically applied at boot time (See ../startup_files/ccfg.c). Calling this function will discard the CCFG setting and adjust relative to the FCFG setting.

Note
Adjusted value will not take effect before XOSC_HF is stopped and restarted
Parameters
capArrDeltaspecifies number of step to adjust the cap array relative to the factory setting.
Returns
None
315 {
316  // read the MODE_CONF register in CCFG
317  uint32_t ccfg_ModeConfReg = HWREG( CCFG_BASE + CCFG_O_MODE_CONF );
318  // Clear CAP_MODE and the CAPARRAY_DELATA field
320  // Insert new delta value
321  ccfg_ModeConfReg |= ((((uint32_t)capArrDelta) << CCFG_MODE_CONF_XOSC_CAPARRAY_DELTA_S ) & CCFG_MODE_CONF_XOSC_CAPARRAY_DELTA_M );
322  // Update the HW register with the new delta value
324 }
uint32_t SetupGetTrimForAnabypassValue1(uint32_t ccfg_ModeConfReg)
Returns the trim value to be used for the ANABYPASS_VALUE1 register in OSC_DIG.
Definition: setup_rom.c:391
void DDI32RegWrite(uint32_t ui32Base, uint32_t ui32Reg, uint32_t ui32Val)
Write a 32 bit value to a register in the DDI slave.
Definition: ddi.c:66

Here is the call graph for this function:

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()
333 {
334  // Estimate HPOSC frequency, using temperature and curve fitting parameters
335  uint32_t fitParams = HWREG(FCFG1_BASE + FCFG1_O_FREQ_OFFSET);
336  // Extract the P0,P1,P2 params, and sign extend them via shifting up/down
337  int32_t paramP0 = ((((int32_t) fitParams) << (32 - FCFG1_FREQ_OFFSET_HPOSC_COMP_P0_W - FCFG1_FREQ_OFFSET_HPOSC_COMP_P0_S))
339  int32_t paramP1 = ((((int32_t) fitParams) << (32 - FCFG1_FREQ_OFFSET_HPOSC_COMP_P1_W - FCFG1_FREQ_OFFSET_HPOSC_COMP_P1_S))
341  int32_t paramP2 = ((((int32_t) fitParams) << (32 - FCFG1_FREQ_OFFSET_HPOSC_COMP_P2_W - FCFG1_FREQ_OFFSET_HPOSC_COMP_P2_S))
343  int32_t paramP3 = ((((int32_t) HWREG(FCFG1_BASE + FCFG1_O_MISC_CONF_2))
346 
347  // Now we can find the HPOSC freq offset, given as a signed variable d, expressed by:
348  //
349  // F_HPOSC = F_nom * (1 + d/(2^22)) , where: F_HPOSC = HPOSC frequency
350  // F_nom = nominal clock source frequency (e.g. 48.000 MHz)
351  // d = describes relative freq offset
352 
353  // We can estimate the d variable, using temperature compensation parameters:
354  //
355  // d = P0 + P1*(t - T0) + P2*(t - T0)^2 + P3*(t - T0)^3, where: P0,P1,P2,P3 are curve fitting parameters from FCFG1
356  // t = current temperature (from temp sensor) in deg C
357  // T0 = 27 deg C (fixed temperature constant)
358  int32_t tempDelta = (tempDegC - 27);
359  int32_t tempDeltaX2 = tempDelta * tempDelta;
360  int32_t d = paramP0 + ((tempDelta*paramP1)>>3) + ((tempDeltaX2*paramP2)>>10) + ((tempDeltaX2*tempDelta*paramP3)>>18);
361 
362  return ( d );
363 }
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).
Parameters
HPOSC_RelFreqOffsetis the relative frequency offset parameter d returned from OSC_HPOSCRelativeFrequencyOffsetGet()
Returns
Returns the relative frequency offset in RF Core format.
See also
OSC_HPOSCRelativeFrequencyOffsetGet()
372 {
373  // The input argument, hereby referred to simply as "d", describes the frequency offset
374  // of the HPOSC relative to the nominal frequency in this way:
375  //
376  // F_HPOSC = F_nom * (1 + d/(2^22))
377  //
378  // But for use by the radio, to compensate the frequency error, we need to find the
379  // frequency offset "rfcFreqOffset" defined in the following format:
380  //
381  // F_nom = F_HPOSC * (1 + rfCoreFreqOffset/(2^22))
382  //
383  // To derive "rfCoreFreqOffset" from "d" we combine the two above equations and get:
384  //
385  // (1 + rfCoreFreqOffset/(2^22)) = (1 + d/(2^22))^-1
386  //
387  // Which can be rewritten into:
388  //
389  // rfCoreFreqOffset = -d*(2^22) / ((2^22) + d)
390  //
391  // = -d * [ 1 / (1 + d/(2^22)) ]
392  //
393  // To avoid doing a 64-bit division due to the (1 + d/(2^22))^-1 expression,
394  // we can use Taylor series (Maclaurin series) to approximate it:
395  //
396  // 1 / (1 - x) ~= 1 + x + x^2 + x^3 + x^4 + ... etc (Maclaurin series)
397  //
398  // In our case, we have x = - d/(2^22), and we only include up to the first
399  // order term of the series, as the second order term ((d^2)/(2^44)) is very small:
400  //
401  // freqError ~= -d + d^2/(2^22) (+ small approximation error)
402  //
403  // The approximation error is negligible for our use.
404 
405  int32_t rfCoreFreqOffset = -HPOSC_RelFreqOffset + (( HPOSC_RelFreqOffset * HPOSC_RelFreqOffset ) >> 22 );
406 
407  return ( rfCoreFreqOffset );
408 }
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()
202 {
206 }
void DDI16BitfieldWrite(uint32_t ui32Base, uint32_t ui32Reg, uint32_t ui32Mask, uint32_t ui32Shift, uint16_t ui32Data)
Write a bit field 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()
179 {
183 }
void DDI16BitfieldWrite(uint32_t ui32Base, uint32_t ui32Reg, uint32_t ui32Mask, uint32_t ui32Shift, uint16_t ui32Data)
Write a bit field 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().

151 {
152  uint32_t ui32ClockSource;
153 
154  // Check the arguments.
155  ASSERT((ui32SrcClk & OSC_SRC_CLK_LF) ||
156  (ui32SrcClk & OSC_SRC_CLK_HF));
157 
158  // Return the source for the selected clock.
159  if(ui32SrcClk == OSC_SRC_CLK_LF)
160  {
164  }
165  else
166  {
170  }
171  return (ui32ClockSource);
172 }
#define OSC_SRC_CLK_HF
Definition: osc.h:113
#define OSC_SRC_CLK_LF
Definition: osc.h:115
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:73

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().

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

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.
247 {
248  uint32_t startupTimeInUs;
249  uint32_t prevLimmit25InUs;
250 
251 #if ( defined( ROM_OSCClockSourceGet ))
252  if ( ROM_OSCClockSourceGet( OSC_SRC_CLK_HF ) == OSC_XOSC_HF )
253 #else
255 #endif
256  {
257  // Already on XOSC - nothing to do
258  return ( 1 );
259  }
260  if ( OSCHfSourceReady()) {
262 
263  // Store startup time, but limit to 25 percent reduction each time.
266  prevLimmit25InUs = oscHfGlobals.previousStartupTimeInUs;
267  prevLimmit25InUs -= ( prevLimmit25InUs >> 2 ); // 25 percent margin
268  oscHfGlobals.previousStartupTimeInUs = startupTimeInUs;
269  if ( prevLimmit25InUs > startupTimeInUs ) {
270  oscHfGlobals.previousStartupTimeInUs = prevLimmit25InUs;
271  }
272  return ( 1 );
273  }
274  return ( 0 );
275 }
static void OSCHfSourceSwitch(void)
Switch the high frequency clock.
Definition: osc.h:315
uint32_t timeXoscStable_CV
Definition: osc.c:91
uint32_t OSCClockSourceGet(uint32_t ui32SrcClk)
Get the source clock settings.
Definition: osc.c:150
#define OSC_SRC_CLK_HF
Definition: osc.h:113
static bool OSCHfSourceReady(void)
Check if the HF clock source is ready to be switched.
Definition: osc.h:287
#define OSC_XOSC_HF
Definition: osc.h:118
uint32_t previousStartupTimeInUs
Definition: osc.c:88
static OscHfGlobals_t oscHfGlobals
Definition: osc.c:95
uint32_t timeXoscOn_CV
Definition: osc.c:90
#define RTC_CV_TO_US(x)
Definition: osc.c:85
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()
417 {
418  uint32_t oscCfgRegCopy ;
419  uint32_t startTime ;
420  uint32_t deltaTime ;
421  uint32_t ampValue ;
422 
423  // The specified method is as follows:
424  // 1. Set minimum interval between oscillator amplitude calibrations.
425  // (Done by setting PER_M=0 and PER_E=1)
426  // 2. Wait approximately 4 milliseconds in order to measure over a
427  // moderately large number of calibrations.
428  // 3. Read out the crystal amplitude value from the peek detector.
429  // 4. Restore original oscillator amplitude calibrations interval.
430  // 5. Return crystal amplitude value converted to millivolt.
431  oscCfgRegCopy = HWREG( AON_WUC_BASE + AON_WUC_O_OSCCFG );
433  startTime = AONRTCCurrentCompareValueGet();
434  do {
435  deltaTime = AONRTCCurrentCompareValueGet() - startTime;
436  } while ( deltaTime < ((uint32_t)( 0.004 * FACTOR_SEC_TO_COMP_VAL_FORMAT )));
437  ampValue = ( HWREG( AUX_DDI0_OSC_BASE + DDI_0_OSC_O_STAT1 ) &
440  HWREG( AON_WUC_BASE + AON_WUC_O_OSCCFG ) = oscCfgRegCopy;
441 
442  return ( ampValue * 15 );
443 }
#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()
452 {
453  uint32_t ampCompTh1 ;
454  uint32_t highThreshold ;
455  uint32_t lowThreshold ;
456 
457  ampCompTh1 = HWREG( AUX_DDI0_OSC_BASE + DDI_0_OSC_O_AMPCOMPTH1 );
458  highThreshold = ( ampCompTh1 & DDI_0_OSC_AMPCOMPTH1_HPMRAMP3_HTH_M ) >>
460  lowThreshold = ( ampCompTh1 & DDI_0_OSC_AMPCOMPTH1_HPMRAMP3_LTH_M ) >>
462 
463  return ((( highThreshold + lowThreshold ) * 15 ) >> 1 );
464 }
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.
181 {
182  uint32_t deltaTimeSinceXoscOnInMs ;
183  int32_t deltaTempSinceXoscOn ;
184  uint32_t newStartupTimeInUs ;
185 
186  deltaTimeSinceXoscOnInMs = RTC_CV_TO_MS( AONRTCCurrentCompareValueGet() - oscHfGlobals.timeXoscOn_CV );
187  deltaTempSinceXoscOn = AONBatMonTemperatureGetDegC() - oscHfGlobals.tempXoscOff;
188 
189  if ( deltaTempSinceXoscOn < 0 ) {
190  deltaTempSinceXoscOn = -deltaTempSinceXoscOn;
191  }
192 
193  if ( (( timeUntilWakeupInMs + deltaTimeSinceXoscOnInMs ) > 3000 ) ||
194  ( deltaTempSinceXoscOn > 5 ) ||
197  {
198  newStartupTimeInUs = 2000;
200  newStartupTimeInUs = (( HWREG( CCFG_BASE + CCFG_O_MODE_CONF_1 ) &
203  // Note: CCFG startup time is "in units of 100us" adding 25% margin results in *125
204  }
205  } else {
207  newStartupTimeInUs += ( newStartupTimeInUs >> 2 ); // Add 25 percent margin
208  if ( newStartupTimeInUs < oscHfGlobals.previousStartupTimeInUs ) {
209  newStartupTimeInUs = oscHfGlobals.previousStartupTimeInUs;
210  }
211  }
212 
213  if ( newStartupTimeInUs < 200 ) {
214  newStartupTimeInUs = 200;
215  }
216  if ( newStartupTimeInUs > 4000 ) {
217  newStartupTimeInUs = 4000;
218  }
219  return ( newStartupTimeInUs );
220 }
uint32_t timeXoscStable_CV
Definition: osc.c:91
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:88
static OscHfGlobals_t oscHfGlobals
Definition: osc.c:95
int32_t tempXoscOff
Definition: osc.c:92
uint32_t timeXoscOn_CV
Definition: osc.c:90
#define RTC_CV_TO_US(x)
Definition: osc.c:85
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:84

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
285 {
286  // Set SCLK_HF and SCLK_MF to RCOSC_HF without checking
287  // Doing this anyway to keep HF and MF in sync
288 #if ( defined( ROM_OSCClockSourceSet ))
289  ROM_OSCClockSourceSet( OSC_SRC_CLK_HF | OSC_SRC_CLK_MF, OSC_RCOSC_HF );
290 #else
292 #endif
293 
294  // Do the switching if not already running on RCOSC_HF
295 #if ( defined( ROM_OSCClockSourceGet ))
296  if ( ROM_OSCClockSourceGet( OSC_SRC_CLK_HF ) != OSC_RCOSC_HF )
297 #else
299 #endif
300  {
302  }
303 
306 }
static void OSCHfSourceSwitch(void)
Switch the high frequency clock.
Definition: osc.h:315
#define OSC_SRC_CLK_MF
Definition: osc.h:114
uint32_t timeXoscOff_CV
Definition: osc.c:89
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:150
#define OSC_SRC_CLK_HF
Definition: osc.h:113
#define OSC_RCOSC_HF
Definition: osc.h:117
static OscHfGlobals_t oscHfGlobals
Definition: osc.c:95
int32_t tempXoscOff
Definition: osc.c:92
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:103

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
230 {
231 #if ( defined( ROM_OSCClockSourceSet ))
232  ROM_OSCClockSourceSet( OSC_SRC_CLK_HF | OSC_SRC_CLK_MF, OSC_XOSC_HF );
233 #else
235 #endif
237 }
#define OSC_SRC_CLK_MF
Definition: osc.h:114
#define OSC_SRC_CLK_HF
Definition: osc.h:113
#define OSC_XOSC_HF
Definition: osc.h:118
static OscHfGlobals_t oscHfGlobals
Definition: osc.c:95
uint32_t timeXoscOn_CV
Definition: osc.c:90
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:103

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().

288 {
289  // Return the readiness of the HF clock source
293  true : false;
294 }
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().

316 {
317  // Switch the HF clock source
319 }
#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
152 {
153  // Check the arguments.
154  ASSERT((ui32Mode == LOW_POWER_XOSC) ||
155  (ui32Mode == HIGH_POWER_XOSC));
156 
157  // Change the power mode.
159  ui32Mode);
160 }
#define LOW_POWER_XOSC
Definition: osc.h:105
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:106
#define ASSERT(expr)
Definition: debug.h:73

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