CC13xx 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
318 {
319  // read the MODE_CONF register in CCFG
320  uint32_t ccfg_ModeConfReg = HWREG( CCFG_BASE + CCFG_O_MODE_CONF );
321  // Clear CAP_MODE and the CAPARRAY_DELATA field
323  // Insert new delta value
324  ccfg_ModeConfReg |= ((((uint32_t)capArrDelta) << CCFG_MODE_CONF_XOSC_CAPARRAY_DELTA_S ) & CCFG_MODE_CONF_XOSC_CAPARRAY_DELTA_M );
325  // Update the HW register with the new delta value
327 }
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:470
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()
336 {
337  // Estimate HPOSC frequency, using temperature and curve fitting parameters
338 
339  uint32_t fitParams = HWREG( FCFG1_BASE + FCFG1_O_FREQ_OFFSET );
340  // Extract the P0,P1,P2 params, and sign extend them via shifting up/down
341  int32_t paramP0 = (((int32_t)( fitParams << ( 32 - FCFG1_FREQ_OFFSET_HPOSC_COMP_P0_W - FCFG1_FREQ_OFFSET_HPOSC_COMP_P0_S )))
343  int32_t paramP1 = (((int32_t)( fitParams << ( 32 - FCFG1_FREQ_OFFSET_HPOSC_COMP_P1_W - FCFG1_FREQ_OFFSET_HPOSC_COMP_P1_S )))
345  int32_t paramP2 = (((int32_t)( fitParams << ( 32 - FCFG1_FREQ_OFFSET_HPOSC_COMP_P2_W - FCFG1_FREQ_OFFSET_HPOSC_COMP_P2_S )))
347 
348  uint32_t fitParP3 = HWREG( FCFG1_BASE + FCFG1_O_MISC_CONF_2 );
349  // Extract the P3 param, and sign extend via shifting up/down
350  int32_t paramP3 = (((int32_t)( fitParP3 << ( 32 - FCFG1_MISC_CONF_2_HPOSC_COMP_P3_W - FCFG1_MISC_CONF_2_HPOSC_COMP_P3_S )))
352 
353  // Now we can find the HPOSC freq offset, given as a signed variable d, expressed by:
354  //
355  // F_HPOSC = F_nom * (1 + d/(2^22)) , where: F_HPOSC = HPOSC frequency
356  // F_nom = nominal clock source frequency (e.g. 48.000 MHz)
357  // d = describes relative freq offset
358 
359  // We can estimate the d variable, using temperature compensation parameters:
360  //
361  // d = P0 + P1*(t - T0) + P2*(t - T0)^2 + P3*(t - T0)^3, where: P0,P1,P2,P3 are curve fitting parameters from FCFG1
362  // t = current temperature (from temp sensor) in deg C
363  // T0 = 27 deg C (fixed temperature constant)
364  int32_t tempDelta = (tempDegC - 27);
365  int32_t tempDeltaX2 = tempDelta * tempDelta;
366  int32_t d = paramP0 + ((tempDelta*paramP1)>>3) + ((tempDeltaX2*paramP2)>>10) + ((tempDeltaX2*tempDelta*paramP3)>>18);
367 
368  return ( d );
369 }
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()
378 {
379  // The input argument, hereby referred to simply as "d", describes the frequency offset
380  // of the HPOSC relative to the nominal frequency in this way:
381  //
382  // F_HPOSC = F_nom * (1 + d/(2^22))
383  //
384  // But for use by the radio, to compensate the frequency error, we need to find the
385  // frequency offset "rfcFreqOffset" defined in the following format:
386  //
387  // F_nom = F_HPOSC * (1 + rfCoreFreqOffset/(2^22))
388  //
389  // To derive "rfCoreFreqOffset" from "d" we combine the two above equations and get:
390  //
391  // (1 + rfCoreFreqOffset/(2^22)) = (1 + d/(2^22))^-1
392  //
393  // Which can be rewritten into:
394  //
395  // rfCoreFreqOffset = -d*(2^22) / ((2^22) + d)
396  //
397  // = -d * [ 1 / (1 + d/(2^22)) ]
398  //
399  // To avoid doing a 64-bit division due to the (1 + d/(2^22))^-1 expression,
400  // we can use Taylor series (Maclaurin series) to approximate it:
401  //
402  // 1 / (1 - x) ~= 1 + x + x^2 + x^3 + x^4 + ... etc (Maclaurin series)
403  //
404  // In our case, we have x = - d/(2^22), and we only include up to the first
405  // order term of the series, as the second order term ((d^2)/(2^44)) is very small:
406  //
407  // freqError ~= -d + d^2/(2^22) (+ small approximation error)
408  //
409  // The approximation error is negligible for our use.
410 
411  int32_t rfCoreFreqOffset = -HPOSC_RelFreqOffset + (( HPOSC_RelFreqOffset * HPOSC_RelFreqOffset ) >> 22 );
412 
413  return ( rfCoreFreqOffset );
414 }
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().

152 {
153  uint32_t ui32ClockSource;
154 
155  // Check the arguments.
156  ASSERT((ui32SrcClk & OSC_SRC_CLK_LF) ||
157  (ui32SrcClk & OSC_SRC_CLK_HF));
158 
159  // Return the source for the selected clock.
160  if(ui32SrcClk == OSC_SRC_CLK_LF)
161  {
165  }
166  else
167  {
171  }
172  return (ui32ClockSource);
173 }
#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 bit field 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 (OSC_SRC_CLK_HF), this function will not do the actual switch. Enabling the high frequency XTAL can take several hundred micro seconds, so the actual switch is done in a separate function, OSCHfSourceSwitch(), 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(), OSCHfSourceSwitch()
Returns
None

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

105 {
106  // Check the arguments.
107  ASSERT((ui32SrcClk & OSC_SRC_CLK_LF) ||
108  (ui32SrcClk & OSC_SRC_CLK_MF) ||
109  (ui32SrcClk & OSC_SRC_CLK_HF));
110  ASSERT((ui32Osc == OSC_RCOSC_HF) ||
111  (ui32Osc == OSC_RCOSC_LF) ||
112  (ui32Osc == OSC_XOSC_HF) ||
113  (ui32Osc == OSC_XOSC_LF));
114 
115  // Request the high frequency source clock (using 24 MHz XTAL)
116  if(ui32SrcClk & OSC_SRC_CLK_HF)
117  {
118  // Enable the HF XTAL as HF clock source
122  ui32Osc);
123  }
124 
125  // Configure the medium frequency source clock
126  if(ui32SrcClk & OSC_SRC_CLK_MF)
127  {
131  ui32Osc);
132  }
133 
134  // Configure the low frequency source clock.
135  if(ui32SrcClk & OSC_SRC_CLK_LF)
136  {
137  // Change the clock source.
141  ui32Osc);
142  }
143 }
#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.
250 {
251  uint32_t startupTimeInUs;
252  uint32_t prevLimmit25InUs;
253 
254 #if ( defined( ROM_OSCClockSourceGet ))
255  if ( ROM_OSCClockSourceGet( OSC_SRC_CLK_HF ) == OSC_XOSC_HF )
256 #else
258 #endif
259  {
260  // Already on XOSC - nothing to do
261  return ( 1 );
262  }
263  if ( OSCHfSourceReady()) {
265 
266  // Store startup time, but limit to 25 percent reduction each time.
269  prevLimmit25InUs = oscHfGlobals.previousStartupTimeInUs;
270  prevLimmit25InUs -= ( prevLimmit25InUs >> 2 ); // 25 percent margin
271  oscHfGlobals.previousStartupTimeInUs = startupTimeInUs;
272  if ( prevLimmit25InUs > startupTimeInUs ) {
273  oscHfGlobals.previousStartupTimeInUs = prevLimmit25InUs;
274  }
275  return ( 1 );
276  }
277  return ( 0 );
278 }
static void OSCHfSourceSwitch(void)
Switch the high frequency clock.
Definition: osc.h:315
uint32_t timeXoscStable_CV
Definition: osc.c:92
uint32_t OSCClockSourceGet(uint32_t ui32SrcClk)
Get the source clock settings.
Definition: osc.c:151
#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:89
static OscHfGlobals_t oscHfGlobals
Definition: osc.c:96
uint32_t timeXoscOn_CV
Definition: osc.c:91
#define RTC_CV_TO_US(x)
Definition: osc.c:86
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()
423 {
424  uint32_t oscCfgRegCopy ;
425  uint32_t startTime ;
426  uint32_t deltaTime ;
427  uint32_t ampValue ;
428 
429  // The specified method is as follows:
430  // 1. Set minimum interval between oscillator amplitude calibrations.
431  // (Done by setting PER_M=0 and PER_E=1)
432  // 2. Wait approximately 4 milliseconds in order to measure over a
433  // moderately large number of calibrations.
434  // 3. Read out the crystal amplitude value from the peek detector.
435  // 4. Restore original oscillator amplitude calibrations interval.
436  // 5. Return crystal amplitude value converted to millivolt.
437  oscCfgRegCopy = HWREG( AON_WUC_BASE + AON_WUC_O_OSCCFG );
439  startTime = AONRTCCurrentCompareValueGet();
440  do {
441  deltaTime = AONRTCCurrentCompareValueGet() - startTime;
442  } while ( deltaTime < ((uint32_t)( 0.004 * FACTOR_SEC_TO_COMP_VAL_FORMAT )));
443  ampValue = ( HWREG( AUX_DDI0_OSC_BASE + DDI_0_OSC_O_STAT1 ) &
446  HWREG( AON_WUC_BASE + AON_WUC_O_OSCCFG ) = oscCfgRegCopy;
447 
448  return ( ampValue * 15 );
449 }
#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()
458 {
459  uint32_t ampCompTh1 ;
460  uint32_t highThreshold ;
461  uint32_t lowThreshold ;
462 
463  ampCompTh1 = HWREG( AUX_DDI0_OSC_BASE + DDI_0_OSC_O_AMPCOMPTH1 );
464  highThreshold = ( ampCompTh1 & DDI_0_OSC_AMPCOMPTH1_HPMRAMP3_HTH_M ) >>
466  lowThreshold = ( ampCompTh1 & DDI_0_OSC_AMPCOMPTH1_HPMRAMP3_LTH_M ) >>
468 
469  return ((( highThreshold + lowThreshold ) * 15 ) >> 1 );
470 }
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.
182 {
183  uint32_t deltaTimeSinceXoscOnInMs ;
184  int32_t deltaTempSinceXoscOn ;
185  uint32_t newStartupTimeInUs ;
186 
187  {
188  deltaTimeSinceXoscOnInMs = RTC_CV_TO_MS( AONRTCCurrentCompareValueGet() - oscHfGlobals.timeXoscOn_CV );
189  deltaTempSinceXoscOn = AONBatMonTemperatureGetDegC() - oscHfGlobals.tempXoscOff;
190 
191  if ( deltaTempSinceXoscOn < 0 ) {
192  deltaTempSinceXoscOn = -deltaTempSinceXoscOn;
193  }
194 
195  if ( (( timeUntilWakeupInMs + deltaTimeSinceXoscOnInMs ) > 3000 ) ||
196  ( deltaTempSinceXoscOn > 5 ) ||
199  {
200  newStartupTimeInUs = 2000;
202  newStartupTimeInUs = (( HWREG( CCFG_BASE + CCFG_O_MODE_CONF_1 ) &
205  // Note: CCFG startup time is "in units of 100us" adding 25% margin results in *125
206  }
207  } else {
209  newStartupTimeInUs += ( newStartupTimeInUs >> 2 ); // Add 25 percent margin
210  if ( newStartupTimeInUs < oscHfGlobals.previousStartupTimeInUs ) {
211  newStartupTimeInUs = oscHfGlobals.previousStartupTimeInUs;
212  }
213  }
214 
215  if ( newStartupTimeInUs < 200 ) {
216  newStartupTimeInUs = 200;
217  }
218  if ( newStartupTimeInUs > 4000 ) {
219  newStartupTimeInUs = 4000;
220  }
221  }
222  return ( newStartupTimeInUs );
223 }
uint32_t timeXoscStable_CV
Definition: osc.c:92
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:89
static OscHfGlobals_t oscHfGlobals
Definition: osc.c:96
int32_t tempXoscOff
Definition: osc.c:93
uint32_t timeXoscOn_CV
Definition: osc.c:91
#define RTC_CV_TO_US(x)
Definition: osc.c:86
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:85

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
288 {
289  // Set SCLK_HF and SCLK_MF to RCOSC_HF without checking
290  // Doing this anyway to keep HF and MF in sync
291 #if ( defined( ROM_OSCClockSourceSet ))
292  ROM_OSCClockSourceSet( OSC_SRC_CLK_HF | OSC_SRC_CLK_MF, OSC_RCOSC_HF );
293 #else
295 #endif
296 
297  // Do the switching if not already running on RCOSC_HF
298 #if ( defined( ROM_OSCClockSourceGet ))
299  if ( ROM_OSCClockSourceGet( OSC_SRC_CLK_HF ) != OSC_RCOSC_HF )
300 #else
302 #endif
303  {
305  }
306 
309 }
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:90
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:151
#define OSC_SRC_CLK_HF
Definition: osc.h:113
#define OSC_RCOSC_HF
Definition: osc.h:117
static OscHfGlobals_t oscHfGlobals
Definition: osc.c:96
int32_t tempXoscOff
Definition: osc.c:93
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:104

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
233 {
234 #if ( defined( ROM_OSCClockSourceSet ))
235  ROM_OSCClockSourceSet( OSC_SRC_CLK_HF | OSC_SRC_CLK_MF, OSC_XOSC_HF );
236 #else
238 #endif
240 }
#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:96
uint32_t timeXoscOn_CV
Definition: osc.c:91
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:104

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 bit field 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