CC26xx Driver Library
[osc.h] Oscillator

Data Structures

struct  HposcDebugData_t
 Data structure for experimental HPOSC polynomials calculation. More...
 

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...
 
static bool OSC_IsHPOSCEnabled (void)
 Identifies if HPOSC is enabled. More...
 
static bool OSC_IsHPOSCEnabledWithHfDerivedLfClock (void)
 Identifies if HPOSC is enabled and that SCLK_LF is derived from XOSC_HF. 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...
 
uint32_t OSCHF_DebugGetCrystalStartupTime (void)
 Measure the crystal startup time. More...
 
void OSC_HPOSCInitializeFrequencyOffsetParameters (void)
 HPOSC initialization function. Must always be called before using HPOSC. More...
 
void OSC_HPOSC_Debug_InitFreqOffsetParams (HposcDebugData_t *pDebugData)
 Debug function to calculate the HPOSC polynomials for experimental data sets. More...
 
void OSC_HPOSCInitializeSingleInsertionFreqOffsParams (uint32_t measFieldAddress)
 Special HPOSC initialization function for single temperature compensation. More...
 
int32_t OSC_HPOSCRelativeFrequencyOffsetGet (int32_t tempDegC)
 Calculate the temperature dependent relative frequency offset of HPOSC. More...
 
void OSC_CapArrayAdjustWorkaround_Boot (void)
 Special XOSC_HF workaround adjustment for CC13x2 / CC26x2 XOSC_CAPARRAY_DELTA setting in CCFG (Customer configuration) 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...
 
void OSC_HPOSCRtcCompensate (int32_t relFreqOffset)
 Compensate the RTC increment based on the relative frequency offset of HPOSC. More...
 

Detailed Description

Function Documentation

§ OSC_AdjustXoscHfCapArray()

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
385 {
387  // Workaround for chip settings like 0x701F0 and 0x701FE which get readjusted with baseline 7001F/6.1pF
389  } else
390  {
391  // Read the MODE_CONF register in CCFG
392  uint32_t ccfg_ModeConfReg = HWREG( CCFG_BASE + CCFG_O_MODE_CONF );
393  // Clear CAP_MODE and the CAPARRAY_DELATA field
395  // Insert new delta value
396  ccfg_ModeConfReg |= ((((uint32_t)capArrDelta) << CCFG_MODE_CONF_XOSC_CAPARRAY_DELTA_S ) & CCFG_MODE_CONF_XOSC_CAPARRAY_DELTA_M );
397  // Update the HW register with the new delta value
399  }
400 }
static void InternCapArrayAdjustWithBaseline7001F(int32_t capArrayDelta)
Definition: osc.c:325
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:436
static uint32_t SpecialCapArrayWorkaroundEnabledAndNeeded(void)
Definition: osc.c:341
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:64
Here is the call graph for this function:

§ OSC_CapArrayAdjustWorkaround_Boot()

void OSC_CapArrayAdjustWorkaround_Boot ( void  )

Special XOSC_HF workaround adjustment for CC13x2 / CC26x2 XOSC_CAPARRAY_DELTA setting in CCFG (Customer configuration)

Implements a workaround for devices with an unfortunate XOSH_HF CAPARRAY factory configuration (FCFG1 setting). The workaround is done only if both enabled and needed (enabled by setting CCFG_SIZE_AND_DIS_FLAGS_DIS_LINEAR_CAPARRAY_DELTA_WORKAROUND = 0) The factory configuration works fine on its own but does not comply with the requirements of the CCFG:XOSC_CAPARRAY_DELTA mechanism. Without this workaround, there will be a larger jump in capacitance (and frequency) between XOSC_CAPARRAY_DELTA setting 7 and 8.

Returns
None
See also
OSC_AdjustXoscHfCapArray()

Referenced by TrimAfterColdResetWakeupFromShutDown().

360 {
361  uint32_t ccfg_ModeConfReg ;
362  int32_t ccfg_CapArrayDelta ;
363 
365  // Workaround for chip settings like 0x701F0 and 0x701FE which get readjusted with baseline 7001F/6.1pF
366  ccfg_CapArrayDelta = 0 ;
367  ccfg_ModeConfReg = HWREG( CCFG_BASE + CCFG_O_MODE_CONF );
368  if (( ccfg_ModeConfReg & CCFG_MODE_CONF_XOSC_CAP_MOD ) == 0 ) {
369  // CCFG CapArrayDelta is enabled get sign-extended delta
370  ccfg_CapArrayDelta =
371  (((int32_t)( ccfg_ModeConfReg << ( 32 - CCFG_MODE_CONF_XOSC_CAPARRAY_DELTA_W - CCFG_MODE_CONF_XOSC_CAPARRAY_DELTA_S )))
373  }
374  InternCapArrayAdjustWithBaseline7001F( ccfg_CapArrayDelta );
375  }
376 }
static void InternCapArrayAdjustWithBaseline7001F(int32_t capArrayDelta)
Definition: osc.c:325
static uint32_t SpecialCapArrayWorkaroundEnabledAndNeeded(void)
Definition: osc.c:341
Here is the call graph for this function:

§ OSC_HPOSC_Debug_InitFreqOffsetParams()

void OSC_HPOSC_Debug_InitFreqOffsetParams ( HposcDebugData_t pDebugData)

Debug function to calculate the HPOSC polynomials for experimental data sets.

Parameters
pDebugDatapointer to the input data collected in HposcDebugData_t
Returns
None
See also
OSC_HPOSCInitializeFrequencyOffsetParameters()
598 {
599  /* Initialize HPOSC internal parameter */
600  hposc_insertions_t hposcMeas;
601  int64_t pu0[3],pu1[3],pu2[3] = {0};
602  hposc_param_t hposcParm =
603  {
604  .pu0b = {42, 32, 27, 20},
605  .pu0c = {-284,-184,536,-104798},
606  .pu1b = {36, 32, 27, 20},
607  .pu1c = {-1155,44130,-319090,-3563},
608  .pu2b = {36, 32, 27, 20},
609  .pu2c = {-3410,261727,-32194,-116627}
610  };
611 
612  /* Retrieve insertions from FCFG */
613  readTempAndFreq((uint32_t)&pDebugData->meas_1, &hposcMeas.temp[0], &hposcMeas.dFreq[0], pDebugData->offsetD1);
614  readTempAndFreq((uint32_t)&pDebugData->meas_2, &hposcMeas.temp[1], &hposcMeas.dFreq[1], pDebugData->offsetD2);
615  readTempAndFreq((uint32_t)&pDebugData->meas_3, &hposcMeas.temp[2], &hposcMeas.dFreq[2], pDebugData->offsetD3);
616 
617  /* Compute HPOSC polynomial coefficients */
618  findHposcPc(hposcParm.pu0c, hposcParm.pu0b, &hposcMeas.temp[0], 3, pu0);
619  findHposcPc(hposcParm.pu1c, hposcParm.pu1b, &hposcMeas.temp[0], 3, pu1);
620  findHposcPc(hposcParm.pu2c, hposcParm.pu2b, &hposcMeas.temp[0], 3, pu2);
621  findHposcCoefficients(&hposcMeas.dFreq[0], pu0, pu1, pu2, &hposcParm);
622 }
uint8_t pu2b[4]
Definition: osc.c:431
int32_t offsetD3
Offset to measurement set 3.
Definition: osc.h:540
int32_t offsetD1
Offset to measurement set 1.
Definition: osc.h:538
int64_t pu0c[4]
Definition: osc.c:432
static void readTempAndFreq(uint32_t regAddr, int32_t *pTemp, int32_t *pdFreq, int32_t deltaFreq)
Definition: osc.c:546
uint32_t meas_1
Measurement set 1 (typically at room temp)
Definition: osc.h:535
Definition: osc.c:421
uint32_t meas_3
Measurement set 3 (typically at low temp)
Definition: osc.h:537
int64_t pu1c[4]
Definition: osc.c:433
int32_t offsetD2
Offset to measurement set 2.
Definition: osc.h:539
static void findHposcCoefficients(int32_t *pInput, int64_t *col0, int64_t *col1, int64_t *col2, hposc_param_t *pParam)
Definition: osc.c:473
static void findHposcPc(int64_t *pCoeff, uint8_t *pBits, int32_t *pTemp, uint8_t nTemp, int64_t *pOutput)
Definition: osc.c:529
uint32_t meas_2
Measurement set 2 (typically at high temp)
Definition: osc.h:536
int32_t dFreq[3]
Definition: osc.c:424
uint8_t pu0b[4]
Definition: osc.c:429
uint8_t pu1b[4]
Definition: osc.c:430
Definition: osc.c:427
int64_t pu2c[4]
Definition: osc.c:434
int32_t temp[3]
Definition: osc.c:423
Here is the call graph for this function:

§ OSC_HPOSCInitializeFrequencyOffsetParameters()

void OSC_HPOSCInitializeFrequencyOffsetParameters ( void  )

HPOSC initialization function. Must always be called before using HPOSC.

Calculates the fitting curve parameters (polynomials) to be used by the HPOSC temperature compensation.

Returns
None
See also
OSC_HPOSC_Debug_InitFreqOffsetParams(), OSC_HPOSCInitializeSingleInsertionFreqOffsParams()

Referenced by OSC_IsHPOSCEnabledWithHfDerivedLfClock().

567 {
568  /* Initialize HPOSC internal parameter */
569  hposc_insertions_t hposcMeas;
570  int64_t pu0[3],pu1[3],pu2[3] = {0};
571  hposc_param_t hposcParm =
572  {
573  .pu0b = {42, 32, 27, 20},
574  .pu0c = {-284,-184,536,-104798},
575  .pu1b = {36, 32, 27, 20},
576  .pu1c = {-1155,44130,-319090,-3563},
577  .pu2b = {36, 32, 27, 20},
578  .pu2c = {-3410,261727,-32194,-116627}
579  };
580 
581  /* Retrieve insertions from FCFG */
582  readTempAndFreq(FCFG1_BASE + FCFG1_O_HPOSC_MEAS_1, &hposcMeas.temp[0], &hposcMeas.dFreq[0], D1OFFSET_25C);
583  readTempAndFreq(FCFG1_BASE + FCFG1_O_HPOSC_MEAS_2, &hposcMeas.temp[1], &hposcMeas.dFreq[1], D2OFFSET_85C);
584  readTempAndFreq(FCFG1_BASE + FCFG1_O_HPOSC_MEAS_3, &hposcMeas.temp[2], &hposcMeas.dFreq[2], D3OFFSET_n40C);
585 
586  /* Compute HPOSC polynomial coefficients */
587  findHposcPc(hposcParm.pu0c, hposcParm.pu0b, &hposcMeas.temp[0], 3, pu0);
588  findHposcPc(hposcParm.pu1c, hposcParm.pu1b, &hposcMeas.temp[0], 3, pu1);
589  findHposcPc(hposcParm.pu2c, hposcParm.pu2b, &hposcMeas.temp[0], 3, pu2);
590  findHposcCoefficients(&hposcMeas.dFreq[0], pu0, pu1, pu2, &hposcParm);
591 }
uint8_t pu2b[4]
Definition: osc.c:431
int64_t pu0c[4]
Definition: osc.c:432
#define D3OFFSET_n40C
Definition: osc.c:410
static void readTempAndFreq(uint32_t regAddr, int32_t *pTemp, int32_t *pdFreq, int32_t deltaFreq)
Definition: osc.c:546
Definition: osc.c:421
#define D2OFFSET_85C
Definition: osc.c:409
int64_t pu1c[4]
Definition: osc.c:433
static void findHposcCoefficients(int32_t *pInput, int64_t *col0, int64_t *col1, int64_t *col2, hposc_param_t *pParam)
Definition: osc.c:473
static void findHposcPc(int64_t *pCoeff, uint8_t *pBits, int32_t *pTemp, uint8_t nTemp, int64_t *pOutput)
Definition: osc.c:529
int32_t dFreq[3]
Definition: osc.c:424
uint8_t pu0b[4]
Definition: osc.c:429
uint8_t pu1b[4]
Definition: osc.c:430
Definition: osc.c:427
int64_t pu2c[4]
Definition: osc.c:434
int32_t temp[3]
Definition: osc.c:423
#define D1OFFSET_25C
Definition: osc.c:408
Here is the call graph for this function:

§ OSC_HPOSCInitializeSingleInsertionFreqOffsParams()

void OSC_HPOSCInitializeSingleInsertionFreqOffsParams ( uint32_t  measFieldAddress)

Special HPOSC initialization function for single temperature compensation.

Used when a single temperature offset measurement is available. This is espesially designed to get a better crystal performance (SW TCXO) on the SiP module but can also be usful to get better crystal performance over the entire temperature range on a standard design as well.

Returns
None
See also
OSC_HPOSCInitializeFrequencyOffsetParameters()
631 {
632  /* Initialize HPOSC internal parameter */
633  hposc_insertions_t hposcMeas;
634  int64_t pu0;
635  hposc_param_t hposcParm =
636  {
637  /* Coefficients for SW-TCXO */
638  .pu0b = {44, 44, 27, 20},
639  .pu0c = {8183, -2546, -210, -104866}
640  };
641 
642  /* Retrieve insertions from FCFG */
643  readTempAndFreq( measFieldAddress, &hposcMeas.temp[0], &hposcMeas.dFreq[0], 0);
644 
645  /* Compute HPOSC polynomial coefficients */
646  findHposcPc(hposcParm.pu0c, hposcParm.pu0b, &hposcMeas.temp[0], 1, &pu0);
647  findHposcCoefficients(&hposcMeas.dFreq[0], &pu0, NULL, NULL, &hposcParm);
648 }
int64_t pu0c[4]
Definition: osc.c:432
static void readTempAndFreq(uint32_t regAddr, int32_t *pTemp, int32_t *pdFreq, int32_t deltaFreq)
Definition: osc.c:546
Definition: osc.c:421
static void findHposcCoefficients(int32_t *pInput, int64_t *col0, int64_t *col1, int64_t *col2, hposc_param_t *pParam)
Definition: osc.c:473
static void findHposcPc(int64_t *pCoeff, uint8_t *pBits, int32_t *pTemp, uint8_t nTemp, int64_t *pOutput)
Definition: osc.c:529
int32_t dFreq[3]
Definition: osc.c:424
uint8_t pu0b[4]
Definition: osc.c:429
Definition: osc.c:427
int32_t temp[3]
Definition: osc.c:423
Here is the call graph for this function:

§ OSC_HPOSCRelativeFrequencyOffsetGet()

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()
657 {
658  // Estimate HPOSC frequency offset, using temperature and curve fitting parameters
659 
660  // Now we can find the HPOSC freq offset, given as a signed variable d, expressed by:
661  //
662  // F_HPOSC = F_nom * (1 + d/(2^22)) , where: F_HPOSC = HPOSC frequency
663  // F_nom = nominal clock source frequency (e.g. 48.000 MHz)
664  // d = describes relative freq offset
665 
666  // We can estimate the d variable, using temperature compensation parameters:
667  //
668  // d = P[3]*(t - T0)^3 + P[2]*(t - T0)^2 + P[1]*(t - T0) + P[0], where: P0,P1,P2,P3 are curve fitting parameters
669  // t = current temperature (from temp sensor) in deg C
670  // T0 = 27 deg C (fixed temperature constant)
671 
672  int32_t d,t1,t2,t3;
673 
674  t1 = tempDegC - 27;
675  t2 = t1 * t1;
676  t3 = t2 * t1;
677 
678  d = ((((int64_t)_hposcCoeffs[3]*t3 + (int64_t)_hposcCoeffs[2]*t2 + (int64_t)_hposcCoeffs[1]*t1) >> HPOSC_COEFF0_SHIFT) +
679  (int64_t)_hposcCoeffs[0]) >> HPOSC_COEFF0_BITS;
680 
681  return ( d );
682 }
#define HPOSC_COEFF0_SHIFT
Definition: osc.c:415
#define HPOSC_COEFF0_BITS
Definition: osc.c:413
int32_t _hposcCoeffs[4]
Definition: osc.c:419

§ OSC_HPOSCRelativeFrequencyOffsetToRFCoreFormatConvert()

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()
691 {
692  // The input argument, hereby referred to simply as "d", describes the frequency offset
693  // of the HPOSC relative to the nominal frequency in this way:
694  //
695  // F_HPOSC = F_nom * (1 + d/(2^22))
696  //
697  // But for use by the radio, to compensate the frequency error, we need to find the
698  // frequency offset "rfcFreqOffset" defined in the following format:
699  //
700  // F_nom = F_HPOSC * (1 + rfCoreFreqOffset/(2^22))
701  //
702  // To derive "rfCoreFreqOffset" from "d" we combine the two above equations and get:
703  //
704  // (1 + rfCoreFreqOffset/(2^22)) = (1 + d/(2^22))^-1
705  //
706  // Which can be rewritten into:
707  //
708  // rfCoreFreqOffset = -d*(2^22) / ((2^22) + d)
709  //
710  // = -d * [ 1 / (1 + d/(2^22)) ]
711  //
712  // To avoid doing a 64-bit division due to the (1 + d/(2^22))^-1 expression,
713  // we can use Taylor series (Maclaurin series) to approximate it:
714  //
715  // 1 / (1 - x) ~= 1 + x + x^2 + x^3 + x^4 + ... etc (Maclaurin series)
716  //
717  // In our case, we have x = - d/(2^22), and we only include up to the first
718  // order term of the series, as the second order term ((d^2)/(2^44)) is very small:
719  //
720  // freqError ~= -d + d^2/(2^22) (+ small approximation error)
721  //
722  // The approximation error is negligible for our use.
723 
724  int32_t rfCoreFreqOffset = -HPOSC_RelFreqOffset + (( HPOSC_RelFreqOffset * HPOSC_RelFreqOffset ) >> 22 );
725 
726  return ( rfCoreFreqOffset );
727 }

§ OSC_HPOSCRtcCompensate()

void OSC_HPOSCRtcCompensate ( int32_t  relFreqOffset)

Compensate the RTC increment based on the relative frequency offset of HPOSC.

The HPOSC (High Precision Oscillator) frequency will vary slightly with chip temperature. This variation forces the RTC increment to be compensated if SCLK_LF is configured to be derived from the HF clock of HPOSC. This function must only be called if SCLK_LF is configured to be derived from the HF clock of HPOSC. The status of this configuration can be determined by calling the OSC_IsHPOSCEnabledWithHfDerivedLfClock() function.

This function first calculates the HPOSC frequency, 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 given by the input argument relFreqOffset. Then the SCLK_LF frequency is calculated, defined as:
        F_SCLK_LF = F_HPOSC / 1536
    
    Then the RTC increment SUBSECINC is calculated, defined as;
        SUBSECINC = (2^38) / F_SCLK_LF
    
    Finally the RTC module is updated with the calculated SUBSECINC value.
Parameters
relFreqOffsetis the relative frequency offset parameter d returned from OSC_HPOSCRelativeFrequencyOffsetGet()
Returns
None
736 {
737  uint32_t rtcSubSecInc;
738  uint32_t lfClkFrequency;
739  uint32_t hfFreq;
740  int64_t calcFactor;
741 
742  // Calculate SCLK_HF frequency, defined as:
743  // hfFreq = 48000000 * (1 + relFreqOffset/(2^22))
744  if( relFreqOffset >= 0 )
745  {
746  calcFactor = ( ( 48000000 * (int64_t)relFreqOffset ) + 0x200000 ) / 0x400000;
747  }
748  else
749  {
750  calcFactor = ( ( 48000000 * (int64_t)relFreqOffset ) - 0x200000 ) / 0x400000;
751  }
752  hfFreq = 48000000 + calcFactor;
753 
754  // Calculate SCLK_LF frequency, defined as SCLK_LF_FREQ = SCLK_HF_FREQ / 1536
755  lfClkFrequency = ( hfFreq + 768 ) / 1536;
756 
757  // Calculate SUBSECINC, defined as: SUBSECINC = 2^38 / SCLK_LF_FREQ
758  rtcSubSecInc = 0x4000000000 / lfClkFrequency;
759 
760  /* Update SUBSECINC value */
761  SetupSetAonRtcSubSecInc(rtcSubSecInc);
762 }
void SetupSetAonRtcSubSecInc(uint32_t subSecInc)
Doing the tricky stuff needed to enter new RTCSUBSECINC value.
Definition: setup_rom.c:927
Here is the call graph for this function:

§ OSC_IsHPOSCEnabled()

static bool OSC_IsHPOSCEnabled ( void  )
inlinestatic

Identifies if HPOSC is enabled.

This function checks if the device supports HPOSC and that HPOSC is selected as HF oscillator for use when the radio is active.

Returns
Returns status of HPOSC functionality:
  • true : HPOSC is enabled.
  • false : HPOSC is not enabled.
353 {
354  bool enabled = false;
355 
358  {
359  enabled = true;
360  }
361 
362  return (enabled);
363 }

§ OSC_IsHPOSCEnabledWithHfDerivedLfClock()

static bool OSC_IsHPOSCEnabledWithHfDerivedLfClock ( void  )
inlinestatic

Identifies if HPOSC is enabled and that SCLK_LF is derived from XOSC_HF.

This function checks if the device supports HPOSC and that HPOSC is selected as HF oscillator for use when the radio is active and also that SCLK_LF is derived from XOSC_HF.

Returns
Returns status of HPOSC and SCLK_LF configuration:
  • true : HPOSC is enabled and SCLK_LF is derived from XOSC_HF.
  • false : Either HPOSC not enabled or SCLK_LF is not derived from XOSC_HF.
380 {
381  bool enabled = false;
382 
383  // Check configuration by reading lower half of the 32-bit CTL0 register
384  uint16_t regVal = HWREGH(AUX_DDI0_OSC_BASE + DDI_0_OSC_O_CTL0);
387  {
388  enabled = true;
389  }
390 
391  return (enabled);
392 }
Here is the call graph for this function:

§ OSCClockLossEventDisable()

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()
204 {
208 }
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:115
Here is the call graph for this function:

§ OSCClockLossEventEnable()

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()
181 {
185 }
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:115
Here is the call graph for this function:

§ OSCClockSourceGet()

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 OSCClockLossEventDisable(), OSCHF_AttemptToSwitchToXosc(), OSCHF_SwitchToRcOscTurnOffXosc(), and SetupAfterColdResetWakeupFromShutDownCfg3().

153 {
154  uint32_t ui32ClockSource;
155 
156  // Check the arguments.
157  ASSERT((ui32SrcClk & OSC_SRC_CLK_LF) ||
158  (ui32SrcClk & OSC_SRC_CLK_HF));
159 
160  // Return the source for the selected clock.
161  if(ui32SrcClk == OSC_SRC_CLK_LF)
162  {
166  }
167  else
168  {
172  }
173  return ( ui32ClockSource );
174 }
#define OSC_SRC_CLK_HF
Definition: osc.h:119
#define OSC_SRC_CLK_LF
Definition: osc.h:120
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:183
#define ASSERT(expr)
Definition: debug.h:71
Here is the call graph for this function:

§ OSCClockSourceSet()

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) 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 OSCClockLossEventDisable(), OSCHF_SwitchToRcOscTurnOffXosc(), OSCHF_TurnOnXosc(), and SetupAfterColdResetWakeupFromShutDownCfg3().

116 {
117  // Check the arguments.
118  ASSERT((ui32SrcClk & OSC_SRC_CLK_LF) ||
119  (ui32SrcClk & OSC_SRC_CLK_HF));
120  ASSERT((ui32Osc == OSC_RCOSC_HF) ||
121  (ui32Osc == OSC_RCOSC_LF) ||
122  (ui32Osc == OSC_XOSC_HF) ||
123  (ui32Osc == OSC_XOSC_LF));
124 
125  // Request the high frequency source clock (using 24 MHz XTAL)
126  if(ui32SrcClk & OSC_SRC_CLK_HF)
127  {
128  // Enable the HF XTAL as HF clock source
132  ui32Osc);
133  }
134 
135  // Configure the low frequency source clock.
136  if(ui32SrcClk & OSC_SRC_CLK_LF)
137  {
138  // Change the clock source.
142  ui32Osc);
143  }
144 }
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:115
#define OSC_SRC_CLK_HF
Definition: osc.h:119
#define OSC_RCOSC_HF
Definition: osc.h:122
#define OSC_XOSC_HF
Definition: osc.h:123
#define OSC_SRC_CLK_LF
Definition: osc.h:120
#define ASSERT(expr)
Definition: debug.h:71
#define OSC_RCOSC_LF
Definition: osc.h:124
#define OSC_XOSC_LF
Definition: osc.h:125
Here is the call graph for this function:

§ OSCHF_AttemptToSwitchToXosc()

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.

Referenced by OSC_IsHPOSCEnabledWithHfDerivedLfClock(), and OSCHF_DebugGetCrystalStartupTime().

260 {
261  uint32_t startupTimeInUs;
262  uint32_t prevLimmit25InUs;
263 
264 #if ( defined( ROM_OSCClockSourceGet ))
266 #else
268 #endif
269  {
270  // Already on XOSC - nothing to do
271  return ( 1 );
272  }
273  if ( OSCHfSourceReady()) {
275 
276  // Store startup time, but limit to 25 percent reduction each time.
279  prevLimmit25InUs = oscHfGlobals.previousStartupTimeInUs;
280  prevLimmit25InUs -= ( prevLimmit25InUs >> 2 ); // 25 percent margin
281  oscHfGlobals.previousStartupTimeInUs = startupTimeInUs;
282  if ( prevLimmit25InUs > startupTimeInUs ) {
283  oscHfGlobals.previousStartupTimeInUs = prevLimmit25InUs;
284  }
285  return ( 1 );
286  }
287  return ( 0 );
288 }
static void OSCHfSourceSwitch(void)
Switch the high frequency clock.
Definition: osc.h:314
#define ROM_OSCClockSourceGet
Definition: rom.h:688
uint32_t timeXoscStable_CV
Definition: osc.c:103
uint32_t OSCClockSourceGet(uint32_t ui32SrcClk)
Get the source clock settings.
Definition: osc.c:152
#define OSC_SRC_CLK_HF
Definition: osc.h:119
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:123
uint32_t previousStartupTimeInUs
Definition: osc.c:100
static OscHfGlobals_t oscHfGlobals
Definition: osc.c:107
uint32_t timeXoscOn_CV
Definition: osc.c:102
#define RTC_CV_TO_US(x)
Definition: osc.c:97
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:818
Here is the call graph for this function:

§ OSCHF_DebugGetCrystalAmplitude()

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

Referenced by OSC_IsHPOSCEnabledWithHfDerivedLfClock().

771 {
772  uint32_t oscCfgRegCopy ;
773  uint32_t startTime ;
774  uint32_t deltaTime ;
775  uint32_t ampValue ;
776 
777  // The specified method is as follows:
778  // 1. Set minimum interval between oscillator amplitude calibrations.
779  // (Done by setting PER_M=0 and PER_E=1)
780  // 2. Wait approximately 4 milliseconds in order to measure over a
781  // moderately large number of calibrations.
782  // 3. Read out the crystal amplitude value from the peek detector.
783  // 4. Restore original oscillator amplitude calibrations interval.
784  // 5. Return crystal amplitude value converted to millivolt.
785  oscCfgRegCopy = HWREG( AON_PMCTL_BASE + AON_PMCTL_O_OSCCFG );
787  startTime = AONRTCCurrentCompareValueGet();
788  do {
789  deltaTime = AONRTCCurrentCompareValueGet() - startTime;
790  } while ( deltaTime < ((uint32_t)( 0.004 * FACTOR_SEC_TO_COMP_VAL_FORMAT )));
791  ampValue = ( HWREG( AUX_DDI0_OSC_BASE + DDI_0_OSC_O_STAT1 ) &
794  HWREG( AON_PMCTL_BASE + AON_PMCTL_O_OSCCFG ) = oscCfgRegCopy;
795 
796  return ( ampValue * 15 );
797 }
#define FACTOR_SEC_TO_COMP_VAL_FORMAT
Definition: aon_rtc.h:149
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:818
Here is the call graph for this function:

§ OSCHF_DebugGetCrystalStartupTime()

uint32_t OSCHF_DebugGetCrystalStartupTime ( void  )

Measure the crystal startup time.

Note
This is a debug function that should not be needed in normal operation.

This function assumes that the chip is running on RCOSC_HF when called. It then switches to XOSC_HF while measuring number of LF-clock edges before XOSC_HF has started and are ready to be used. After that, the function switches back to RCOSC_HF and returns number of LF-edges found.

The length in time between the LF clock edges is approximately 15 microseconds. Or more exactly: LF_clock_edges / ( 32768 * 2 ) seconds.

Please note that the startup time, in addition to the crystal itself also can vary depending on the time since the crystal was stopped and the frequency of the RCOSC_HF oscillator. Calling this function intensively will show a shorter startup time than in typical use cases. When running with TI-RTOS there is a background task (optional but default on) adjusting RCOSC_HF to be as equal as possible to the crystal frequency, giving the shortest possible startup time.

Returns
Returns number of LF-clock edges from starting the crystal until it's ready to be used.

Referenced by OSC_IsHPOSCEnabledWithHfDerivedLfClock().

826 {
827  uint32_t lfEdgesFound = 0 ;
828 
829  // Start operation in sync with the LF clock
830  HWREG( AON_RTC_BASE + AON_RTC_O_SYNCLF );
831 
833  while ( ! OSCHF_AttemptToSwitchToXosc() ) {
834  HWREG( AON_RTC_BASE + AON_RTC_O_SYNCLF );
835  lfEdgesFound ++ ;
836  }
838 
839  return ( lfEdgesFound );
840 }
bool OSCHF_AttemptToSwitchToXosc(void)
Switch to XOSC_HF if XOSC_HF is ready.
Definition: osc.c:259
void OSCHF_SwitchToRcOscTurnOffXosc(void)
Switch to RCOSC_HF and turn off XOSC_HF.
Definition: osc.c:297
void OSCHF_TurnOnXosc(void)
Turns on XOSC_HF (but without switching to XOSC_HF).
Definition: osc.c:242
Here is the call graph for this function:

§ OSCHF_DebugGetExpectedAverageCrystalAmplitude()

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

Referenced by OSC_IsHPOSCEnabledWithHfDerivedLfClock().

806 {
807  uint32_t ampCompTh1 ;
808  uint32_t highThreshold ;
809  uint32_t lowThreshold ;
810 
811  ampCompTh1 = HWREG( AUX_DDI0_OSC_BASE + DDI_0_OSC_O_AMPCOMPTH1 );
812  highThreshold = ( ampCompTh1 & DDI_0_OSC_AMPCOMPTH1_HPMRAMP3_HTH_M ) >>
814  lowThreshold = ( ampCompTh1 & DDI_0_OSC_AMPCOMPTH1_HPMRAMP3_LTH_M ) >>
816 
817  return ((( highThreshold + lowThreshold ) * 15 ) >> 1 );
818 }

§ OSCHF_GetStartupTime()

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.

Referenced by OSC_IsHPOSCEnabledWithHfDerivedLfClock().

183 {
184  uint32_t deltaTimeSinceXoscOnInMs ;
185  int32_t deltaTempSinceXoscOn ;
186  uint32_t newStartupTimeInUs ;
187 
188  // Check CCFG to determine if device is configured for TCXO.
190  {
191  // Device configured for TCXO. Report fixed startup time located in CCFG with
192  // coversion from number of 100us to number of us.
193  newStartupTimeInUs = (( HWREG( CCFG_BASE + CCFG_O_MODE_CONF_1 ) & CCFG_MODE_CONF_1_TCXO_MAX_START_M ) >>
195  }
196  else
197  {
198  deltaTimeSinceXoscOnInMs = RTC_CV_TO_MS( AONRTCCurrentCompareValueGet() - oscHfGlobals.timeXoscOn_CV );
199  deltaTempSinceXoscOn = AONBatMonTemperatureGetDegC() - oscHfGlobals.tempXoscOff;
200 
201  if ( deltaTempSinceXoscOn < 0 ) {
202  deltaTempSinceXoscOn = -deltaTempSinceXoscOn;
203  }
204 
205  if ( (( timeUntilWakeupInMs + deltaTimeSinceXoscOnInMs ) > 3000 ) ||
206  ( deltaTempSinceXoscOn > 5 ) ||
209  {
210  newStartupTimeInUs = 2000;
212  newStartupTimeInUs = (( HWREG( CCFG_BASE + CCFG_O_MODE_CONF_1 ) &
215  // Note: CCFG startup time is "in units of 100us" adding 25% margin results in *125
216  }
217  } else {
219  newStartupTimeInUs += ( newStartupTimeInUs >> 2 ); // Add 25 percent margin
220  if ( newStartupTimeInUs < oscHfGlobals.previousStartupTimeInUs ) {
221  newStartupTimeInUs = oscHfGlobals.previousStartupTimeInUs;
222  }
223  }
224 
225  if ( newStartupTimeInUs < 200 ) {
226  newStartupTimeInUs = 200;
227  }
228  if ( newStartupTimeInUs > 4000 ) {
229  newStartupTimeInUs = 4000;
230  }
231  }
232  return ( newStartupTimeInUs );
233 }
uint32_t timeXoscStable_CV
Definition: osc.c:103
int32_t AONBatMonTemperatureGetDegC(void)
Get the current temperature measurement as a signed value in Deg Celsius.
Definition: aon_batmon.c:58
uint32_t previousStartupTimeInUs
Definition: osc.c:100
static OscHfGlobals_t oscHfGlobals
Definition: osc.c:107
int32_t tempXoscOff
Definition: osc.c:104
uint32_t timeXoscOn_CV
Definition: osc.c:102
#define RTC_CV_TO_US(x)
Definition: osc.c:97
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:818
#define RTC_CV_TO_MS(x)
Definition: osc.c:96
Here is the call graph for this function:

§ OSCHF_SwitchToRcOscTurnOffXosc()

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

Referenced by OSC_IsHPOSCEnabledWithHfDerivedLfClock(), and OSCHF_DebugGetCrystalStartupTime().

298 {
299 #if ( defined( ROM_OSCClockSourceSet ))
301 #else
303 #endif
304 
305  // Do the switching if not already running on RCOSC_HF
306 #if ( defined( ROM_OSCClockSourceGet ))
308 #else
310 #endif
311  {
313  }
314 
317 }
static void OSCHfSourceSwitch(void)
Switch the high frequency clock.
Definition: osc.h:314
#define ROM_OSCClockSourceSet
Definition: rom.h:692
uint32_t timeXoscOff_CV
Definition: osc.c:101
#define ROM_OSCClockSourceGet
Definition: rom.h:688
int32_t AONBatMonTemperatureGetDegC(void)
Get the current temperature measurement as a signed value in Deg Celsius.
Definition: aon_batmon.c:58
uint32_t OSCClockSourceGet(uint32_t ui32SrcClk)
Get the source clock settings.
Definition: osc.c:152
#define OSC_SRC_CLK_HF
Definition: osc.h:119
#define OSC_RCOSC_HF
Definition: osc.h:122
static OscHfGlobals_t oscHfGlobals
Definition: osc.c:107
int32_t tempXoscOff
Definition: osc.c:104
void OSCClockSourceSet(uint32_t ui32SrcClk, uint32_t ui32Osc)
Configure the oscillator input to the a source clock.
Definition: osc.c:115
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:818
Here is the call graph for this function:

§ OSCHF_TurnOnXosc()

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

Referenced by OSC_IsHPOSCEnabledWithHfDerivedLfClock(), and OSCHF_DebugGetCrystalStartupTime().

243 {
244 #if ( defined( ROM_OSCClockSourceSet ))
246 #else
248 #endif
250 }
#define ROM_OSCClockSourceSet
Definition: rom.h:692
#define OSC_SRC_CLK_HF
Definition: osc.h:119
#define OSC_XOSC_HF
Definition: osc.h:123
static OscHfGlobals_t oscHfGlobals
Definition: osc.c:107
uint32_t timeXoscOn_CV
Definition: osc.c:102
void OSCClockSourceSet(uint32_t ui32SrcClk, uint32_t ui32Osc)
Configure the oscillator input to the a source clock.
Definition: osc.c:115
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:818
Here is the call graph for this function:

§ OSCHfSourceReady()

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 bit field via the DDI using 16-bit read.
Definition: ddi.c:183
Here is the call graph for this function:

§ OSCHfSourceSwitch()

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  // Read target clock (lower half of the 32-bit CTL0 register)
318 
319  // If target clock source is RCOSC, change clock source for DCDC to RCOSC
321  {
322  // Force DCDC to use RCOSC before switching SCLK_HF to RCOSC
324  // Dummy read to ensure that the write has propagated
326  }
327 
328  // Switch the HF clock source
330 
331  // If target clock source is XOSC, change clock source for DCDC to "auto"
333  {
334  // Set DCDC clock source back to "auto" after SCLK_HF was switched to XOSC
335  HWREG(AUX_DDI0_OSC_BASE + DDI_O_MASK16B + (DDI_0_OSC_O_CTL0 << 1) + 4) = DDI_0_OSC_CTL0_CLK_DCDC_SRC_SEL_M;
336  }
337 }
#define HapiHFSourceSafeSwitch()
Definition: rom.h:152

§ OSCXHfPowerModeSet()

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
154 {
155  // Check the arguments.
156  ASSERT((ui32Mode == LOW_POWER_XOSC) ||
157  (ui32Mode == HIGH_POWER_XOSC));
158 
159  // Change the power mode.
161  ui32Mode);
162 }
#define LOW_POWER_XOSC
Definition: osc.h:111
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:81
#define HIGH_POWER_XOSC
Definition: osc.h:112
#define ASSERT(expr)
Definition: debug.h:71
Here is the call graph for this function:

Macro Definition Documentation

§ HIGH_POWER_XOSC

#define HIGH_POWER_XOSC   0

Referenced by OSCXHfPowerModeSet().

§ LOW_POWER_XOSC

#define LOW_POWER_XOSC   1

Referenced by OSCXHfPowerModeSet().

§ OSC_RCOSC_HF

#define OSC_RCOSC_HF   0x00000000

§ OSC_RCOSC_LF

#define OSC_RCOSC_LF   0x00000002

§ OSC_SRC_CLK_HF

§ OSC_SRC_CLK_LF

#define OSC_SRC_CLK_LF   0x00000004

§ OSC_XOSC_HF

§ OSC_XOSC_LF

#define OSC_XOSC_LF   0x00000003

§ SCLK_HF_RCOSC_HF

#define SCLK_HF_RCOSC_HF   0

§ SCLK_HF_XOSC_HF

#define SCLK_HF_XOSC_HF   1

§ SCLK_LF_FROM_RCOSC_HF

#define SCLK_LF_FROM_RCOSC_HF   0

§ SCLK_LF_FROM_RCOSC_LF

#define SCLK_LF_FROM_RCOSC_LF   2

§ SCLK_LF_FROM_XOSC_HF

#define SCLK_LF_FROM_XOSC_HF   1

§ SCLK_LF_FROM_XOSC_LF

#define SCLK_LF_FROM_XOSC_LF   3