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
303 {
304  // read the MODE_CONF register in CCFG
305  uint32_t ccfg_ModeConfReg = HWREG( CCFG_BASE + CCFG_O_MODE_CONF );
306  // Clear CAP_MODE and the CAPARRAY_DELATA field
308  // Insert new delta value
309  ccfg_ModeConfReg |= ((((uint32_t)capArrDelta) << CCFG_MODE_CONF_XOSC_CAPARRAY_DELTA_S ) & CCFG_MODE_CONF_XOSC_CAPARRAY_DELTA_M );
310  // Update the HW register with the new delta value
312 }
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:438
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()
321 {
322  // Estimate HPOSC frequency, using temperature and curve fitting parameters
323  uint32_t fitParams = HWREG(FCFG1_BASE + FCFG1_O_FREQ_OFFSET);
324  // Extract the P0,P1,P2 params, and sign extend them via shifting up/down
325  int32_t paramP0 = ((((int32_t) fitParams) << (32 - FCFG1_FREQ_OFFSET_HPOSC_COMP_P0_W - FCFG1_FREQ_OFFSET_HPOSC_COMP_P0_S))
327  int32_t paramP1 = ((((int32_t) fitParams) << (32 - FCFG1_FREQ_OFFSET_HPOSC_COMP_P1_W - FCFG1_FREQ_OFFSET_HPOSC_COMP_P1_S))
329  int32_t paramP2 = ((((int32_t) fitParams) << (32 - FCFG1_FREQ_OFFSET_HPOSC_COMP_P2_W - FCFG1_FREQ_OFFSET_HPOSC_COMP_P2_S))
331  int32_t paramP3 = ((((int32_t) HWREG(FCFG1_BASE + FCFG1_O_MISC_CONF_2))
334 
335  // Now we can find the HPOSC freq offset, given as a signed variable d, expressed by:
336  //
337  // F_HPOSC = F_nom * (1 + d/(2^22)) , where: F_HPOSC = HPOSC frequency
338  // F_nom = nominal clock source frequency (e.g. 48.000 MHz)
339  // d = describes relative freq offset
340 
341  // We can estimate the d variable, using temperature compensation parameters:
342  //
343  // d = P0 + P1*(t - T0) + P2*(t - T0)^2 + P3*(t - T0)^3, where: P0,P1,P2,P3 are curve fitting parameters from FCFG1
344  // t = current temperature (from temp sensor) in deg C
345  // T0 = 27 deg C (fixed temperature constant)
346  int32_t tempDelta = (tempDegC - 27);
347  int32_t tempDeltaX2 = tempDelta * tempDelta;
348  int32_t d = paramP0 + ((tempDelta*paramP1)>>3) + ((tempDeltaX2*paramP2)>>10) + ((tempDeltaX2*tempDelta*paramP3)>>18);
349 
350  return ( d );
351 }
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()
360 {
361  // The input argument, hereby referred to simply as "d", describes the frequency offset
362  // of the HPOSC relative to the nominal frequency in this way:
363  //
364  // F_HPOSC = F_nom * (1 + d/(2^22))
365  //
366  // But for use by the radio, to compensate the frequency error, we need to find the
367  // frequency offset "rfcFreqOffset" defined in the following format:
368  //
369  // F_nom = F_HPOSC * (1 + rfCoreFreqOffset/(2^22))
370  //
371  // To derive "rfCoreFreqOffset" from "d" we combine the two above equations and get:
372  //
373  // (1 + rfCoreFreqOffset/(2^22)) = (1 + d/(2^22))^-1
374  //
375  // Which can be rewritten into:
376  //
377  // rfCoreFreqOffset = -d*(2^22) / ((2^22) + d)
378  //
379  // = -d * [ 1 / (1 + d/(2^22)) ]
380  //
381  // To avoid doing a 64-bit division due to the (1 + d/(2^22))^-1 expression,
382  // we can use Taylor series (Maclaurin series) to approximate it:
383  //
384  // 1 / (1 - x) ~= 1 + x + x^2 + x^3 + x^4 + ... etc (Maclaurin series)
385  //
386  // In our case, we have x = - d/(2^22), and we only include up to the first
387  // order term of the series, as the second order term ((d^2)/(2^44)) is very small:
388  //
389  // freqError ~= -d + d^2/(2^22) (+ small approximation error)
390  //
391  // The approximation error is negligible for our use.
392 
393  int32_t rfCoreFreqOffset = -HPOSC_RelFreqOffset + (( HPOSC_RelFreqOffset * HPOSC_RelFreqOffset ) >> 22 );
394 
395  return ( rfCoreFreqOffset );
396 }
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()
198 {
202 }
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()
175 {
179 }
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().

141 {
142  uint32_t ui32ClockSource;
143 
144  // Check the arguments.
145  ASSERT((ui32SrcClk & OSC_SRC_CLK_LF) ||
146  (ui32SrcClk & OSC_SRC_CLK_HF));
147 
148  // Return the source for the selected clock.
149  if(ui32SrcClk == OSC_SRC_CLK_LF)
150  {
154  }
155  else
156  {
160  }
161  return (ui32ClockSource);
162 }
#define OSC_SRC_CLK_HF
Definition: osc.h:113
#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: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) 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_HF));
108  ASSERT((ui32Osc == OSC_RCOSC_HF) ||
109  (ui32Osc == OSC_RCOSC_LF) ||
110  (ui32Osc == OSC_XOSC_HF) ||
111  (ui32Osc == OSC_XOSC_LF));
112 
113  // Request the high frequency source clock (using 24 MHz XTAL)
114  if(ui32SrcClk & OSC_SRC_CLK_HF)
115  {
116  // Enable the HF XTAL as HF clock source
120  ui32Osc);
121  }
122 
123  // Configure the low frequency source clock.
124  if(ui32SrcClk & OSC_SRC_CLK_LF)
125  {
126  // Change the clock source.
130  ui32Osc);
131  }
132 }
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:116
#define OSC_XOSC_HF
Definition: osc.h:117
#define OSC_SRC_CLK_LF
Definition: osc.h:114
#define ASSERT(expr)
Definition: debug.h:73
#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.
237 {
238  uint32_t startupTimeInUs;
239  uint32_t prevLimmit25InUs;
240 
241 #if ( defined( ROM_OSCClockSourceGet ))
243 #else
245 #endif
246  {
247  // Already on XOSC - nothing to do
248  return ( 1 );
249  }
250  if ( OSCHfSourceReady()) {
252 
253  // Store startup time, but limit to 25 percent reduction each time.
256  prevLimmit25InUs = oscHfGlobals.previousStartupTimeInUs;
257  prevLimmit25InUs -= ( prevLimmit25InUs >> 2 ); // 25 percent margin
258  oscHfGlobals.previousStartupTimeInUs = startupTimeInUs;
259  if ( prevLimmit25InUs > startupTimeInUs ) {
260  oscHfGlobals.previousStartupTimeInUs = prevLimmit25InUs;
261  }
262  return ( 1 );
263  }
264  return ( 0 );
265 }
static void OSCHfSourceSwitch(void)
Switch the high frequency clock.
Definition: osc.h:308
#define ROM_OSCClockSourceGet
Definition: rom.h:722
uint32_t timeXoscStable_CV
Definition: osc.c:91
uint32_t OSCClockSourceGet(uint32_t ui32SrcClk)
Get the source clock settings.
Definition: osc.c:140
#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:280
#define OSC_XOSC_HF
Definition: osc.h:117
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
static uint32_t AONRTCCurrentCompareValueGet(void)
Get the current value of the RTC counter in a format that matches RTC compare values.
Definition: aon_rtc.h:819

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()
405 {
406  uint32_t oscCfgRegCopy ;
407  uint32_t startTime ;
408  uint32_t deltaTime ;
409  uint32_t ampValue ;
410 
411  // The specified method is as follows:
412  // 1. Set minimum interval between oscillator amplitude calibrations.
413  // (Done by setting PER_M=0 and PER_E=1)
414  // 2. Wait approximately 4 milliseconds in order to measure over a
415  // moderately large number of calibrations.
416  // 3. Read out the crystal amplitude value from the peek detector.
417  // 4. Restore original oscillator amplitude calibrations interval.
418  // 5. Return crystal amplitude value converted to millivolt.
419  oscCfgRegCopy = HWREG( AON_PMCTL_BASE + AON_PMCTL_O_OSCCFG );
421  startTime = AONRTCCurrentCompareValueGet();
422  do {
423  deltaTime = AONRTCCurrentCompareValueGet() - startTime;
424  } while ( deltaTime < ((uint32_t)( 0.004 * FACTOR_SEC_TO_COMP_VAL_FORMAT )));
425  ampValue = ( HWREG( AUX_DDI0_OSC_BASE + DDI_0_OSC_O_STAT1 ) &
428  HWREG( AON_PMCTL_BASE + AON_PMCTL_O_OSCCFG ) = oscCfgRegCopy;
429 
430  return ( ampValue * 15 );
431 }
#define FACTOR_SEC_TO_COMP_VAL_FORMAT
Definition: aon_rtc.h:150
static uint32_t AONRTCCurrentCompareValueGet(void)
Get the current value of the RTC counter in a format that matches RTC compare values.
Definition: aon_rtc.h:819

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()
440 {
441  uint32_t ampCompTh1 ;
442  uint32_t highThreshold ;
443  uint32_t lowThreshold ;
444 
445  ampCompTh1 = HWREG( AUX_DDI0_OSC_BASE + DDI_0_OSC_O_AMPCOMPTH1 );
446  highThreshold = ( ampCompTh1 & DDI_0_OSC_AMPCOMPTH1_HPMRAMP3_HTH_M ) >>
448  lowThreshold = ( ampCompTh1 & DDI_0_OSC_AMPCOMPTH1_HPMRAMP3_LTH_M ) >>
450 
451  return ((( highThreshold + lowThreshold ) * 15 ) >> 1 );
452 }
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.
171 {
172  uint32_t deltaTimeSinceXoscOnInMs ;
173  int32_t deltaTempSinceXoscOn ;
174  uint32_t newStartupTimeInUs ;
175 
176  deltaTimeSinceXoscOnInMs = RTC_CV_TO_MS( AONRTCCurrentCompareValueGet() - oscHfGlobals.timeXoscOn_CV );
177  deltaTempSinceXoscOn = AONBatMonTemperatureGetDegC() - oscHfGlobals.tempXoscOff;
178 
179  if ( deltaTempSinceXoscOn < 0 ) {
180  deltaTempSinceXoscOn = -deltaTempSinceXoscOn;
181  }
182 
183  if ( (( timeUntilWakeupInMs + deltaTimeSinceXoscOnInMs ) > 3000 ) ||
184  ( deltaTempSinceXoscOn > 5 ) ||
187  {
188  newStartupTimeInUs = 2000;
190  newStartupTimeInUs = (( HWREG( CCFG_BASE + CCFG_O_MODE_CONF_1 ) &
193  // Note: CCFG startup time is "in units of 100us" adding 25% margin results in *125
194  }
195  } else {
197  newStartupTimeInUs += ( newStartupTimeInUs >> 2 ); // Add 25 percent margin
198  if ( newStartupTimeInUs < oscHfGlobals.previousStartupTimeInUs ) {
199  newStartupTimeInUs = oscHfGlobals.previousStartupTimeInUs;
200  }
201  }
202 
203  if ( newStartupTimeInUs < 200 ) {
204  newStartupTimeInUs = 200;
205  }
206  if ( newStartupTimeInUs > 4000 ) {
207  newStartupTimeInUs = 4000;
208  }
209  return ( newStartupTimeInUs );
210 }
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
static uint32_t AONRTCCurrentCompareValueGet(void)
Get the current value of the RTC counter in a format that matches RTC compare values.
Definition: aon_rtc.h:819
#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
275 {
276 #if ( defined( ROM_OSCClockSourceSet ))
278 #else
280 #endif
281 
282  // Do the switching if not already running on RCOSC_HF
283 #if ( defined( ROM_OSCClockSourceGet ))
285 #else
287 #endif
288  {
290  }
291 
294 }
static void OSCHfSourceSwitch(void)
Switch the high frequency clock.
Definition: osc.h:308
#define ROM_OSCClockSourceSet
Definition: rom.h:726
uint32_t timeXoscOff_CV
Definition: osc.c:89
#define ROM_OSCClockSourceGet
Definition: rom.h:722
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:140
#define OSC_SRC_CLK_HF
Definition: osc.h:113
#define OSC_RCOSC_HF
Definition: osc.h:116
static OscHfGlobals_t oscHfGlobals
Definition: osc.c:95
int32_t tempXoscOff
Definition: osc.c:92
void OSCClockSourceSet(uint32_t ui32SrcClk, uint32_t ui32Osc)
Configure the oscillator input to the a source clock.
Definition: osc.c:103
static uint32_t AONRTCCurrentCompareValueGet(void)
Get the current value of the RTC counter in a format that matches RTC compare values.
Definition: aon_rtc.h:819

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
220 {
221 #if ( defined( ROM_OSCClockSourceSet ))
223 #else
225 #endif
227 }
#define ROM_OSCClockSourceSet
Definition: rom.h:726
#define OSC_SRC_CLK_HF
Definition: osc.h:113
#define OSC_XOSC_HF
Definition: osc.h:117
static OscHfGlobals_t oscHfGlobals
Definition: osc.c:95
uint32_t timeXoscOn_CV
Definition: osc.c:90
void OSCClockSourceSet(uint32_t ui32SrcClk, uint32_t ui32Osc)
Configure the oscillator input to the a source clock.
Definition: osc.c:103
static uint32_t AONRTCCurrentCompareValueGet(void)
Get the current value of the RTC counter in a format that matches RTC compare values.
Definition: aon_rtc.h:819

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

281 {
282  // Return the readiness of the HF clock source
286  true : false;
287 }
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().

309 {
310  // Switch the HF clock source
312 }
#define HapiHFSourceSafeSwitch()
Definition: rom.h:153
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
148 {
149  // Check the arguments.
150  ASSERT((ui32Mode == LOW_POWER_XOSC) ||
151  (ui32Mode == HIGH_POWER_XOSC));
152 
153  // Change the power mode.
155  ui32Mode);
156 }
#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_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