CC26xx Driver Library
[setup_rom.h] Setup (ROM functions)

Functions

void SetupAfterColdResetWakeupFromShutDownCfg1 (uint32_t ccfg_ModeConfReg)
 First part of configuration required after cold reset and when waking up from shutdown. More...
 
void SetupAfterColdResetWakeupFromShutDownCfg2 (uint32_t ui32Fcfg1Revision, uint32_t ccfg_ModeConfReg)
 Second part of configuration required after cold reset and when waking up from shutdown. More...
 
void SetupAfterColdResetWakeupFromShutDownCfg3 (uint32_t ccfg_ModeConfReg)
 Third part of configuration required after cold reset and when waking up from shutdown. More...
 
uint32_t SetupGetTrimForAdcShModeEn (uint32_t ui32Fcfg1Revision)
 Returns the trim value from FCFG1 to be used as ADC_SH_MODE_EN setting. More...
 
uint32_t SetupGetTrimForAdcShVbufEn (uint32_t ui32Fcfg1Revision)
 Returns the trim value from FCFG1 to be used as ADC_SH_VBUF_EN setting. More...
 
uint32_t SetupGetTrimForAmpcompCtrl (uint32_t ui32Fcfg1Revision)
 Returns the trim value to be used for the AMPCOMP_CTRL register in OSC_DIG. More...
 
uint32_t SetupGetTrimForAmpcompTh1 (void)
 Returns the trim value to be used for the AMPCOMP_TH1 register in OSC_DIG. More...
 
uint32_t SetupGetTrimForAmpcompTh2 (void)
 Returns the trim value to be used for the AMPCOMP_TH2 register in OSC_DIG. More...
 
uint32_t SetupGetTrimForAnabypassValue1 (uint32_t ccfg_ModeConfReg)
 Returns the trim value to be used for the ANABYPASS_VALUE1 register in OSC_DIG. More...
 
uint32_t SetupGetTrimForDblrLoopFilterResetVoltage (uint32_t ui32Fcfg1Revision)
 Returns the trim value from FCFG1 to be used as DBLR_LOOP_FILTER_RESET_VOLTAGE setting. More...
 
uint32_t SetupGetTrimForRadcExtCfg (uint32_t ui32Fcfg1Revision)
 Returns the trim value to be used for the RADCEXTCFG register in OSC_DIG. More...
 
uint32_t SetupGetTrimForRcOscLfIBiasTrim (uint32_t ui32Fcfg1Revision)
 Returns the FCFG1 OSC_CONF_ATESTLF_RCOSCLF_IBIAS_TRIM. More...
 
uint32_t SetupGetTrimForRcOscLfRtuneCtuneTrim (void)
 Returns the trim value to be used for the RCOSCLF_RTUNE_TRIM and the RCOSCLF_CTUNE_TRIM bit fields in the XOSCLF_RCOSCLF_CTRL register in OSC_DIG. More...
 
uint32_t SetupGetTrimForXoscHfCtl (uint32_t ui32Fcfg1Revision)
 Returns the trim value to be used for the XOSCHFCTL register in OSC_DIG. More...
 
uint32_t SetupGetTrimForXoscHfFastStart (void)
 Returns the trim value to be used as OSC_DIG:CTL1.XOSC_HF_FAST_START. More...
 
uint32_t SetupGetTrimForXoscHfIbiastherm (void)
 Returns the trim value to be used for the XOSC_HF_IBIASTHERM bit field in the ANABYPASS_VALUE2 register in OSC_DIG. More...
 
uint32_t SetupGetTrimForXoscLfRegulatorAndCmirrwrRatio (uint32_t ui32Fcfg1Revision)
 Returns XOSCLF_REGULATOR_TRIM and XOSCLF_CMIRRWR_RATIO as one packet spanning bits [5:0] in the returned value. More...
 
static int32_t SetupSignExtendVddrTrimValue (uint32_t ui32VddrTrimVal)
 Sign extend the VDDR_TRIM setting (special format ranging from -10 to +21) More...
 
void SetupSetCacheModeAccordingToCcfgSetting (void)
 Set correct VIMS_MODE according to CCFG setting (CACHE or GPRAM) More...
 
void SetupSetAonRtcSubSecInc (uint32_t subSecInc)
 Doing the tricky stuff needed to enter new RTCSUBSECINC value. More...
 
void SetupStepVddrTrimTo (uint32_t toCode)
 Set VDDR boost mode (by setting VDDR_TRIM to FCFG1..VDDR_TRIM_HH and setting VDDS_BOD to max) More...
 

Detailed Description

This module contains functions from the Setup API which are likely to be in ROM.

Note
Do not use functions from this module directly! This module is only to be used by SetupTrimDevice().

Function Documentation

§ SetupAfterColdResetWakeupFromShutDownCfg1()

void SetupAfterColdResetWakeupFromShutDownCfg1 ( uint32_t  ccfg_ModeConfReg)

First part of configuration required after cold reset and when waking up from shutdown.

Configures the following based on settings in CCFG (Customer Configuration area:

  • Boost mode for CC13xx devices
  • Minimal VDDR voltage threshold used during sleep mode
  • DCDC functionality:
    • Selects if DCDC or GLDO regulator will be used for VDDR in active mode
    • Selects if DCDC or GLDO regulator will be used for VDDR in sleep mode

In addition the battery monitor low limit for internal regulator mode is set to a hard coded value.

Parameters
ccfg_ModeConfRegis the value of the CCFG_O_MODE_CONF_1 register
Returns
None

Referenced by TrimAfterColdResetWakeupFromShutDown().

167 {
168  // Check for CC1352 boost mode
169  // The combination VDDR_EXT_LOAD=0 and VDDS_BOD_LEVEL=1 is defined to select boost mode
170  if ((( ccfg_ModeConfReg & CCFG_MODE_CONF_VDDR_EXT_LOAD ) == 0 ) &&
171  (( ccfg_ModeConfReg & CCFG_MODE_CONF_VDDS_BOD_LEVEL ) != 0 ) )
172  {
173  // Set VDDS_BOD trim - using masked write {MASK8:DATA8}
174  // - TRIM_VDDS_BOD is bits[7:3] of ADI3..REFSYSCTL1
175  // - Needs a positive transition on BOD_BG_TRIM_EN (bit[7] of REFSYSCTL3) to
176  // latch new VDDS BOD. Set to 0 first to guarantee a positive transition.
177  HWREGB( ADI3_BASE + ADI_O_CLR + ADI_3_REFSYS_O_REFSYSCTL3 ) = ADI_3_REFSYS_REFSYSCTL3_BOD_BG_TRIM_EN;
178  //
179  // VDDS_BOD_LEVEL = 1 means that boost mode is selected
180  // - Max out the VDDS_BOD trim (=VDDS_BOD_POS_31)
181  HWREGH( ADI3_BASE + ADI_O_MASK8B + ( ADI_3_REFSYS_O_REFSYSCTL1 * 2 )) =
182  ( ADI_3_REFSYS_REFSYSCTL1_TRIM_VDDS_BOD_M << 8 ) |
183  ( ADI_3_REFSYS_REFSYSCTL1_TRIM_VDDS_BOD_POS_31 ) ;
184  HWREGB( ADI3_BASE + ADI_O_SET + ADI_3_REFSYS_O_REFSYSCTL3 ) = ADI_3_REFSYS_REFSYSCTL3_BOD_BG_TRIM_EN;
185 
186  SetupStepVddrTrimTo(( HWREG( FCFG1_BASE + FCFG1_O_VOLT_TRIM ) &
187  FCFG1_VOLT_TRIM_VDDR_TRIM_HH_M ) >>
188  FCFG1_VOLT_TRIM_VDDR_TRIM_HH_S ) ;
189  }
190 
191  // 1.
192  // Do not allow DCDC to be enabled if in external regulator mode.
193  // Preventing this by setting both the RECHARGE and the ACTIVE bits bit in the CCFG_MODE_CONF copy register (ccfg_ModeConfReg).
194  //
195  // 2.
196  // Adjusted battery monitor low limit in internal regulator mode.
197  // This is done by setting AON_BATMON_FLASHPUMPP0_LOWLIM=0 in internal regulator mode.
198  if ( HWREG( AON_PMCTL_BASE + AON_PMCTL_O_PWRCTL ) & AON_PMCTL_PWRCTL_EXT_REG_MODE ) {
199  ccfg_ModeConfReg |= ( CCFG_MODE_CONF_DCDC_RECHARGE_M | CCFG_MODE_CONF_DCDC_ACTIVE_M );
200  } else {
201  HWREGBITW( AON_BATMON_BASE + AON_BATMON_O_FLASHPUMPP0, AON_BATMON_FLASHPUMPP0_LOWLIM_BITN ) = 0;
202  }
203 
204  // set the RECHARGE source based upon CCFG:MODE_CONF:DCDC_RECHARGE
205  // Note: Inverse polarity
206  HWREGBITW( AON_PMCTL_BASE + AON_PMCTL_O_PWRCTL, AON_PMCTL_PWRCTL_DCDC_EN_BITN ) =
207  ((( ccfg_ModeConfReg >> CCFG_MODE_CONF_DCDC_RECHARGE_S ) & 1 ) ^ 1 );
208 
209  // set the ACTIVE source based upon CCFG:MODE_CONF:DCDC_ACTIVE
210  // Note: Inverse polarity
211  HWREGBITW( AON_PMCTL_BASE + AON_PMCTL_O_PWRCTL, AON_PMCTL_PWRCTL_DCDC_ACTIVE_BITN ) =
212  ((( ccfg_ModeConfReg >> CCFG_MODE_CONF_DCDC_ACTIVE_S ) & 1 ) ^ 1 );
213 }
void SetupStepVddrTrimTo(uint32_t toCode)
Set VDDR boost mode (by setting VDDR_TRIM to FCFG1..VDDR_TRIM_HH and setting VDDS_BOD to max) ...
Definition: setup_rom.c:118
Here is the call graph for this function:

§ SetupAfterColdResetWakeupFromShutDownCfg2()

void SetupAfterColdResetWakeupFromShutDownCfg2 ( uint32_t  ui32Fcfg1Revision,
uint32_t  ccfg_ModeConfReg 
)

Second part of configuration required after cold reset and when waking up from shutdown.

Configures and trims functionalites required for use of XOSC_HF. The configurations and trimmings are based on settings in FCFG1 (Factory Configuration area) and partly on ccfg_ModeConfReg.

Parameters
ui32Fcfg1Revisionis the value of the FCFG1_O_FCFG1_REVISION register
ccfg_ModeConfRegis the value of the CCFG_O_MODE_CONF_1 register
Returns
None

Referenced by TrimAfterColdResetWakeupFromShutDown().

222 {
223  uint32_t ui32Trim;
224 
225  // Following sequence is required for using XOSCHF, if not included
226  // devices crashes when trying to switch to XOSCHF.
227  //
228  // Trim CAP settings. Get and set trim value for the ANABYPASS_VALUE1
229  // register
230  ui32Trim = SetupGetTrimForAnabypassValue1( ccfg_ModeConfReg );
231  DDI32RegWrite(AUX_DDI0_OSC_BASE, DDI_0_OSC_O_ANABYPASSVAL1, ui32Trim);
232 
233  // Trim RCOSC_LF. Get and set trim values for the RCOSCLF_RTUNE_TRIM and
234  // RCOSCLF_CTUNE_TRIM fields in the XOSCLF_RCOSCLF_CTRL register.
236  DDI16BitfieldWrite(AUX_DDI0_OSC_BASE, DDI_0_OSC_O_LFOSCCTL,
237  (DDI_0_OSC_LFOSCCTL_RCOSCLF_CTUNE_TRIM_M |
238  DDI_0_OSC_LFOSCCTL_RCOSCLF_RTUNE_TRIM_M),
239  DDI_0_OSC_LFOSCCTL_RCOSCLF_CTUNE_TRIM_S,
240  ui32Trim);
241 
242  // Trim XOSCHF IBIAS THERM. Get and set trim value for the
243  // XOSCHF IBIAS THERM bit field in the ANABYPASS_VALUE2 register. Other
244  // register bit fields are set to 0.
245  ui32Trim = SetupGetTrimForXoscHfIbiastherm();
246  DDI32RegWrite(AUX_DDI0_OSC_BASE, DDI_0_OSC_O_ANABYPASSVAL2,
247  ui32Trim<<DDI_0_OSC_ANABYPASSVAL2_XOSC_HF_IBIASTHERM_S);
248 
249  // Trim AMPCOMP settings required before switch to XOSCHF
250  ui32Trim = SetupGetTrimForAmpcompTh2();
251  DDI32RegWrite(AUX_DDI0_OSC_BASE, DDI_0_OSC_O_AMPCOMPTH2, ui32Trim);
252  ui32Trim = SetupGetTrimForAmpcompTh1();
253  DDI32RegWrite(AUX_DDI0_OSC_BASE, DDI_0_OSC_O_AMPCOMPTH1, ui32Trim);
254 #if ( CCFG_BASE == CCFG_BASE_DEFAULT )
255  ui32Trim = SetupGetTrimForAmpcompCtrl( ui32Fcfg1Revision );
256 #else
257  ui32Trim = NOROM_SetupGetTrimForAmpcompCtrl( ui32Fcfg1Revision );
258 #endif
259  DDI32RegWrite(AUX_DDI0_OSC_BASE, DDI_0_OSC_O_AMPCOMPCTL, ui32Trim);
260 
261  // Set trim for DDI_0_OSC_ADCDOUBLERNANOAMPCTL_ADC_SH_MODE_EN in accordance to FCFG1 setting
262  // This is bit[5] in the DDI_0_OSC_O_ADCDOUBLERNANOAMPCTL register
263  // Using MASK4 write + 1 => writing to bits[7:4]
264  ui32Trim = SetupGetTrimForAdcShModeEn( ui32Fcfg1Revision );
265  HWREGB( AUX_DDI0_OSC_BASE + DDI_O_MASK4B + ( DDI_0_OSC_O_ADCDOUBLERNANOAMPCTL * 2 ) + 1 ) =
266  ( 0x20 | ( ui32Trim << 1 ));
267 
268  // Set trim for DDI_0_OSC_ADCDOUBLERNANOAMPCTL_ADC_SH_VBUF_EN in accordance to FCFG1 setting
269  // This is bit[4] in the DDI_0_OSC_O_ADCDOUBLERNANOAMPCTL register
270  // Using MASK4 write + 1 => writing to bits[7:4]
271  ui32Trim = SetupGetTrimForAdcShVbufEn( ui32Fcfg1Revision );
272  HWREGB( AUX_DDI0_OSC_BASE + DDI_O_MASK4B + ( DDI_0_OSC_O_ADCDOUBLERNANOAMPCTL * 2 ) + 1 ) =
273  ( 0x10 | ( ui32Trim ));
274 
275  // Set trim for the PEAK_DET_ITRIM, HP_BUF_ITRIM and LP_BUF_ITRIM bit fields
276  // in the DDI0_OSC_O_XOSCHFCTL register in accordance to FCFG1 setting.
277  // Remaining register bit fields are set to their reset values of 0.
278  ui32Trim = SetupGetTrimForXoscHfCtl(ui32Fcfg1Revision);
279  DDI32RegWrite(AUX_DDI0_OSC_BASE, DDI_0_OSC_O_XOSCHFCTL, ui32Trim);
280 
281  // Set trim for DBLR_LOOP_FILTER_RESET_VOLTAGE in accordance to FCFG1 setting
282  // (This is bits [18:17] in DDI_0_OSC_O_ADCDOUBLERNANOAMPCTL)
283  // (Using MASK4 write + 4 => writing to bits[19:16] => (4*4))
284  // (Assuming: DDI_0_OSC_ADCDOUBLERNANOAMPCTL_DBLR_LOOP_FILTER_RESET_VOLTAGE_S = 17 and
285  // that DDI_0_OSC_ADCDOUBLERNANOAMPCTL_DBLR_LOOP_FILTER_RESET_VOLTAGE_M = 0x00060000)
286  ui32Trim = SetupGetTrimForDblrLoopFilterResetVoltage( ui32Fcfg1Revision );
287  HWREGB( AUX_DDI0_OSC_BASE + DDI_O_MASK4B + ( DDI_0_OSC_O_ADCDOUBLERNANOAMPCTL * 2 ) + 4 ) =
288  ( 0x60 | ( ui32Trim << 1 ));
289 
290  // Update DDI_0_OSC_ATESTCTL_ATESTLF_RCOSCLF_IBIAS_TRIM with data from
291  // FCFG1_OSC_CONF_ATESTLF_RCOSCLF_IBIAS_TRIM
292  // This is DDI_0_OSC_O_ATESTCTL bit[7]
293  // ( DDI_0_OSC_O_ATESTCTL is currently hidden (but=0x00000020))
294  // Using MASK4 write + 1 => writing to bits[7:4]
295  ui32Trim = SetupGetTrimForRcOscLfIBiasTrim( ui32Fcfg1Revision );
296  HWREGB( AUX_DDI0_OSC_BASE + DDI_O_MASK4B + ( 0x00000020 * 2 ) + 1 ) =
297  ( 0x80 | ( ui32Trim << 3 ));
298 
299  // Update DDI_0_OSC_LFOSCCTL_XOSCLF_REGULATOR_TRIM and
300  // DDI_0_OSC_LFOSCCTL_XOSCLF_CMIRRWR_RATIO in one write
301  // This can be simplified since the registers are packed together in the same
302  // order both in FCFG1 and in the HW register.
303  // This spans DDI_0_OSC_O_LFOSCCTL bits[23:18]
304  // Using MASK8 write + 4 => writing to bits[23:16]
305  ui32Trim = SetupGetTrimForXoscLfRegulatorAndCmirrwrRatio( ui32Fcfg1Revision );
306  HWREGH( AUX_DDI0_OSC_BASE + DDI_O_MASK8B + ( DDI_0_OSC_O_LFOSCCTL * 2 ) + 4 ) =
307  ( 0xFC00 | ( ui32Trim << 2 ));
308 
309  // Set trim the HPM_IBIAS_WAIT_CNT, LPM_IBIAS_WAIT_CNT and IDAC_STEP bit
310  // fields in the DDI0_OSC_O_RADCEXTCFG register in accordance to FCFG1 setting.
311  // Remaining register bit fields are set to their reset values of 0.
312  ui32Trim = SetupGetTrimForRadcExtCfg(ui32Fcfg1Revision);
313  DDI32RegWrite(AUX_DDI0_OSC_BASE, DDI_0_OSC_O_RADCEXTCFG, ui32Trim);
314 }
uint32_t SetupGetTrimForAdcShModeEn(uint32_t ui32Fcfg1Revision)
Returns the trim value from FCFG1 to be used as ADC_SH_MODE_EN setting.
Definition: setup_rom.c:723
uint32_t SetupGetTrimForXoscLfRegulatorAndCmirrwrRatio(uint32_t ui32Fcfg1Revision)
Returns XOSCLF_REGULATOR_TRIM and XOSCLF_CMIRRWR_RATIO as one packet spanning bits [5:0] in the retur...
Definition: setup_rom.c:862
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
uint32_t SetupGetTrimForAdcShVbufEn(uint32_t ui32Fcfg1Revision)
Returns the trim value from FCFG1 to be used as ADC_SH_VBUF_EN setting.
Definition: setup_rom.c:742
uint32_t SetupGetTrimForXoscHfCtl(uint32_t ui32Fcfg1Revision)
Returns the trim value to be used for the XOSCHFCTL register in OSC_DIG.
Definition: setup_rom.c:761
uint32_t SetupGetTrimForXoscHfIbiastherm(void)
Returns the trim value to be used for the XOSC_HF_IBIASTHERM bit field in the ANABYPASS_VALUE2 regist...
Definition: setup_rom.c:532
uint32_t SetupGetTrimForRadcExtCfg(uint32_t ui32Fcfg1Revision)
Returns the trim value to be used for the RADCEXTCFG register in OSC_DIG.
Definition: setup_rom.c:811
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
uint32_t SetupGetTrimForRcOscLfIBiasTrim(uint32_t ui32Fcfg1Revision)
Returns the FCFG1 OSC_CONF_ATESTLF_RCOSCLF_IBIAS_TRIM.
Definition: setup_rom.c:843
uint32_t SetupGetTrimForAmpcompTh1(void)
Returns the trim value to be used for the AMPCOMP_TH1 register in OSC_DIG.
Definition: setup_rom.c:587
uint32_t SetupGetTrimForAmpcompCtrl(uint32_t ui32Fcfg1Revision)
Returns the trim value to be used for the AMPCOMP_CTRL register in OSC_DIG.
Definition: setup_rom.c:622
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
uint32_t SetupGetTrimForRcOscLfRtuneCtuneTrim(void)
Returns the trim value to be used for the RCOSCLF_RTUNE_TRIM and the RCOSCLF_CTUNE_TRIM bit fields in...
Definition: setup_rom.c:505
uint32_t SetupGetTrimForDblrLoopFilterResetVoltage(uint32_t ui32Fcfg1Revision)
Returns the trim value from FCFG1 to be used as DBLR_LOOP_FILTER_RESET_VOLTAGE setting.
Definition: setup_rom.c:704
uint32_t SetupGetTrimForAmpcompTh2(void)
Returns the trim value to be used for the AMPCOMP_TH2 register in OSC_DIG.
Definition: setup_rom.c:552
Here is the call graph for this function:

§ SetupAfterColdResetWakeupFromShutDownCfg3()

void SetupAfterColdResetWakeupFromShutDownCfg3 ( uint32_t  ccfg_ModeConfReg)

Third part of configuration required after cold reset and when waking up from shutdown.

Configures the following:

  • XOSC source selection based on ccfg_ModeConfReg. If HPOSC is selected on a HPOSC device the oscillator is configured based on settings in FCFG1 (Factory Configuration area).
  • Clock loss detection is disabled. Will be re-enabled by TIRTOS power driver.
  • Duration of the XOSC_HF fast startup mode based on FCFG1 setting.
  • SCLK_LF based on ccfg_ModeConfReg.
  • Output voltage of ADC fixed reference based on FCFG1 setting.
Parameters
ccfg_ModeConfRegis the value of the CCFG_O_MODE_CONF_1 register
Returns
None

Referenced by TrimAfterColdResetWakeupFromShutDown().

323 {
324  uint32_t fcfg1OscConf;
325  uint32_t ui32Trim;
326  uint32_t currentHfClock;
327  uint32_t ccfgExtLfClk;
328 
329  // Examine the XOSC_FREQ field to select 0x1=HPOSC, 0x2=48MHz XOSC, 0x3=24MHz XOSC
330  switch (( ccfg_ModeConfReg & CCFG_MODE_CONF_XOSC_FREQ_M ) >> CCFG_MODE_CONF_XOSC_FREQ_S ) {
331  case 2 :
332  // XOSC source is a 48 MHz crystal
333  // Do nothing (since this is the reset setting)
334  break;
335  case 1 :
336  // XOSC source is HPOSC (trim the HPOSC if this is a chip with HPOSC, otherwise skip trimming and default to 24 MHz XOSC)
337 
338  fcfg1OscConf = HWREG( FCFG1_BASE + FCFG1_O_OSC_CONF );
339 
340  if (( fcfg1OscConf & FCFG1_OSC_CONF_HPOSC_OPTION ) == 0 ) {
341  // This is a HPOSC chip, apply HPOSC settings
342  // Set bit DDI_0_OSC_CTL0_HPOSC_MODE_EN (this is bit 14 in DDI_0_OSC_O_CTL0)
343  HWREG( AUX_DDI0_OSC_BASE + DDI_O_SET + DDI_0_OSC_O_CTL0 ) = DDI_0_OSC_CTL0_HPOSC_MODE_EN;
344 
345  // ADI_2_REFSYS_HPOSCCTL2_BIAS_HOLD_MODE_EN = FCFG1_OSC_CONF_HPOSC_BIAS_HOLD_MODE_EN (1 bit)
346  // ADI_2_REFSYS_HPOSCCTL2_CURRMIRR_RATIO = FCFG1_OSC_CONF_HPOSC_CURRMIRR_RATIO (4 bits)
347  // ADI_2_REFSYS_HPOSCCTL1_BIAS_RES_SET = FCFG1_OSC_CONF_HPOSC_BIAS_RES_SET (4 bits)
348  // ADI_2_REFSYS_HPOSCCTL0_FILTER_EN = FCFG1_OSC_CONF_HPOSC_FILTER_EN (1 bit)
349  // ADI_2_REFSYS_HPOSCCTL0_BIAS_RECHARGE_DLY = FCFG1_OSC_CONF_HPOSC_BIAS_RECHARGE_DELAY (2 bits)
350  // ADI_2_REFSYS_HPOSCCTL0_SERIES_CAP = FCFG1_OSC_CONF_HPOSC_SERIES_CAP (2 bits)
351  // ADI_2_REFSYS_HPOSCCTL0_DIV3_BYPASS = FCFG1_OSC_CONF_HPOSC_DIV3_BYPASS (1 bit)
352 
353  HWREG( ADI2_BASE + ADI_2_REFSYS_O_HPOSCCTL2 ) = (( HWREG( ADI2_BASE + ADI_2_REFSYS_O_HPOSCCTL2 ) &
354  ~( ADI_2_REFSYS_HPOSCCTL2_BIAS_HOLD_MODE_EN_M | ADI_2_REFSYS_HPOSCCTL2_CURRMIRR_RATIO_M ) ) |
355  ((( fcfg1OscConf & FCFG1_OSC_CONF_HPOSC_BIAS_HOLD_MODE_EN_M ) >> FCFG1_OSC_CONF_HPOSC_BIAS_HOLD_MODE_EN_S ) << ADI_2_REFSYS_HPOSCCTL2_BIAS_HOLD_MODE_EN_S ) |
356  ((( fcfg1OscConf & FCFG1_OSC_CONF_HPOSC_CURRMIRR_RATIO_M ) >> FCFG1_OSC_CONF_HPOSC_CURRMIRR_RATIO_S ) << ADI_2_REFSYS_HPOSCCTL2_CURRMIRR_RATIO_S ) );
357  HWREG( ADI2_BASE + ADI_2_REFSYS_O_HPOSCCTL1 ) = (( HWREG( ADI2_BASE + ADI_2_REFSYS_O_HPOSCCTL1 ) & ~( ADI_2_REFSYS_HPOSCCTL1_BIAS_RES_SET_M ) ) |
358  ((( fcfg1OscConf & FCFG1_OSC_CONF_HPOSC_BIAS_RES_SET_M ) >> FCFG1_OSC_CONF_HPOSC_BIAS_RES_SET_S ) << ADI_2_REFSYS_HPOSCCTL1_BIAS_RES_SET_S ) );
359  HWREG( ADI2_BASE + ADI_2_REFSYS_O_HPOSCCTL0 ) = (( HWREG( ADI2_BASE + ADI_2_REFSYS_O_HPOSCCTL0 ) &
360  ~( ADI_2_REFSYS_HPOSCCTL0_FILTER_EN_M | ADI_2_REFSYS_HPOSCCTL0_BIAS_RECHARGE_DLY_M | ADI_2_REFSYS_HPOSCCTL0_SERIES_CAP_M | ADI_2_REFSYS_HPOSCCTL0_DIV3_BYPASS_M )) |
361  ((( fcfg1OscConf & FCFG1_OSC_CONF_HPOSC_FILTER_EN_M ) >> FCFG1_OSC_CONF_HPOSC_FILTER_EN_S ) << ADI_2_REFSYS_HPOSCCTL0_FILTER_EN_S ) |
362  ((( fcfg1OscConf & FCFG1_OSC_CONF_HPOSC_BIAS_RECHARGE_DELAY_M ) >> FCFG1_OSC_CONF_HPOSC_BIAS_RECHARGE_DELAY_S ) << ADI_2_REFSYS_HPOSCCTL0_BIAS_RECHARGE_DLY_S ) |
363  ((( fcfg1OscConf & FCFG1_OSC_CONF_HPOSC_SERIES_CAP_M ) >> FCFG1_OSC_CONF_HPOSC_SERIES_CAP_S ) << ADI_2_REFSYS_HPOSCCTL0_SERIES_CAP_S ) |
364  ((( fcfg1OscConf & FCFG1_OSC_CONF_HPOSC_DIV3_BYPASS_M ) >> FCFG1_OSC_CONF_HPOSC_DIV3_BYPASS_S ) << ADI_2_REFSYS_HPOSCCTL0_DIV3_BYPASS_S ) );
365  break;
366  }
367  // Not a HPOSC chip - fall through to default
368  default :
369  // XOSC source is a 24 MHz crystal (default)
370  // Set bit DDI_0_OSC_CTL0_XTAL_IS_24M (this is bit 31 in DDI_0_OSC_O_CTL0)
371  HWREG( AUX_DDI0_OSC_BASE + DDI_O_SET + DDI_0_OSC_O_CTL0 ) = DDI_0_OSC_CTL0_XTAL_IS_24M;
372  break;
373  }
374 
375  // Set XOSC_HF in bypass mode if CCFG is configured for external TCXO
376  // Please note that it is up to the customer to make sure that the external clock source is up and running before XOSC_HF can be used.
377  if (( HWREG( CCFG_BASE + CCFG_O_SIZE_AND_DIS_FLAGS ) & CCFG_SIZE_AND_DIS_FLAGS_DIS_TCXO ) == 0 ) {
378  HWREG( AUX_DDI0_OSC_BASE + DDI_O_SET + DDI_0_OSC_O_XOSCHFCTL ) = DDI_0_OSC_XOSCHFCTL_BYPASS;
379  }
380 
381  // Clear DDI_0_OSC_CTL0_CLK_LOSS_EN (ClockLossEventEnable()). This is bit 9 in DDI_0_OSC_O_CTL0.
382  // This is typically already 0 except on Lizard where it is set in ROM-boot
383  HWREG( AUX_DDI0_OSC_BASE + DDI_O_CLR + DDI_0_OSC_O_CTL0 ) = DDI_0_OSC_CTL0_CLK_LOSS_EN;
384 
385  // Setting DDI_0_OSC_CTL1_XOSC_HF_FAST_START according to value found in FCFG1
386  ui32Trim = SetupGetTrimForXoscHfFastStart();
387  HWREGB( AUX_DDI0_OSC_BASE + DDI_O_MASK4B + ( DDI_0_OSC_O_CTL1 * 2 )) = ( 0x30 | ui32Trim );
388 
389  // setup the LF clock based upon CCFG:MODE_CONF:SCLK_LF_OPTION
390  switch (( ccfg_ModeConfReg & CCFG_MODE_CONF_SCLK_LF_OPTION_M ) >> CCFG_MODE_CONF_SCLK_LF_OPTION_S ) {
391  case 0 : // XOSC_HF_DLF (XOSCHF/1536) -> SCLK_LF (=31250 Hz)
393  SetupSetAonRtcSubSecInc( 0x8637BD ); // RTC_INCREMENT = 2^38 / frequency
394  break;
395  case 1 : // EXTERNAL signal -> SCLK_LF (frequency=2^38/CCFG_EXT_LF_CLK_RTC_INCREMENT)
396  // Set SCLK_LF to use the same source as SCLK_HF
397  // Can be simplified a bit since possible return values for HF matches LF settings
398  currentHfClock = OSCClockSourceGet( OSC_SRC_CLK_HF );
399  OSCClockSourceSet( OSC_SRC_CLK_LF, currentHfClock );
400  while( OSCClockSourceGet( OSC_SRC_CLK_LF ) != currentHfClock ) {
401  // Wait until switched
402  }
403  ccfgExtLfClk = HWREG( CCFG_BASE + CCFG_O_EXT_LF_CLK );
404  SetupSetAonRtcSubSecInc(( ccfgExtLfClk & CCFG_EXT_LF_CLK_RTC_INCREMENT_M ) >> CCFG_EXT_LF_CLK_RTC_INCREMENT_S );
405  IOCPortConfigureSet(( ccfgExtLfClk & CCFG_EXT_LF_CLK_DIO_M ) >> CCFG_EXT_LF_CLK_DIO_S,
407  IOC_STD_INPUT | IOC_HYST_ENABLE ); // Route external clock to AON IOC w/hysteresis
408  // Set XOSC_LF in bypass mode to allow external 32 kHz clock
409  HWREG( AUX_DDI0_OSC_BASE + DDI_O_SET + DDI_0_OSC_O_CTL0 ) = DDI_0_OSC_CTL0_XOSC_LF_DIG_BYPASS;
410  // Fall through to set XOSC_LF as SCLK_LF source
411  case 2 : // XOSC_LF -> SLCK_LF (32768 Hz)
413  break;
414  default : // (=3) RCOSC_LF
416  break;
417  }
418 
419  // Update ADI_4_AUX_ADCREF1_VTRIM with value from FCFG1
420  HWREGB( AUX_ADI4_BASE + ADI_4_AUX_O_ADCREF1 ) =
421  ((( HWREG( FCFG1_BASE + FCFG1_O_SOC_ADC_REF_TRIM_AND_OFFSET_EXT ) >>
422  FCFG1_SOC_ADC_REF_TRIM_AND_OFFSET_EXT_SOC_ADC_REF_VOLTAGE_TRIM_TEMP1_S ) <<
423  ADI_4_AUX_ADCREF1_VTRIM_S ) &
424  ADI_4_AUX_ADCREF1_VTRIM_M );
425 
426  // Sync with AON
427  SysCtrlAonSync();
428 }
static void SysCtrlAonSync(void)
Sync all accesses to the AON register interface.
Definition: sys_ctrl.h:336
#define IOC_PORT_AON_CLK32K
Definition: ioc.h:168
uint32_t OSCClockSourceGet(uint32_t ui32SrcClk)
Get the source clock settings.
Definition: osc.c:152
#define IOC_STD_INPUT
Definition: ioc.h:315
#define OSC_SRC_CLK_HF
Definition: osc.h:119
#define OSC_XOSC_HF
Definition: osc.h:123
#define OSC_SRC_CLK_LF
Definition: osc.h:120
void SetupSetAonRtcSubSecInc(uint32_t subSecInc)
Doing the tricky stuff needed to enter new RTCSUBSECINC value.
Definition: setup_rom.c:927
#define OSC_RCOSC_LF
Definition: osc.h:124
void IOCPortConfigureSet(uint32_t ui32IOId, uint32_t ui32PortId, uint32_t ui32IOConfig)
Set the configuration of an IO port.
Definition: ioc.c:96
#define IOC_HYST_ENABLE
Definition: ioc.h:223
void OSCClockSourceSet(uint32_t ui32SrcClk, uint32_t ui32Osc)
Configure the oscillator input to the a source clock.
Definition: osc.c:115
uint32_t SetupGetTrimForXoscHfFastStart(void)
Returns the trim value to be used as OSC_DIG:CTL1.XOSC_HF_FAST_START.
Definition: setup_rom.c:793
#define OSC_XOSC_LF
Definition: osc.h:125
Here is the call graph for this function:

§ SetupGetTrimForAdcShModeEn()

uint32_t SetupGetTrimForAdcShModeEn ( uint32_t  ui32Fcfg1Revision)

Returns the trim value from FCFG1 to be used as ADC_SH_MODE_EN setting.

Parameters
ui32Fcfg1Revisionis the value of the FCFG1_O_FCFG1_REVISION register
Returns
Returns the trim value from FCFG1.

Referenced by SetupAfterColdResetWakeupFromShutDownCfg2().

724 {
725  uint32_t getTrimForAdcShModeEnValue = 1; // Recommended default setting
726 
727  if ( ui32Fcfg1Revision >= 0x00000022 ) {
728  getTrimForAdcShModeEnValue = ( HWREG( FCFG1_BASE + FCFG1_O_OSC_CONF ) &
729  FCFG1_OSC_CONF_ADC_SH_MODE_EN_M ) >>
730  FCFG1_OSC_CONF_ADC_SH_MODE_EN_S;
731  }
732 
733  return ( getTrimForAdcShModeEnValue );
734 }

§ SetupGetTrimForAdcShVbufEn()

uint32_t SetupGetTrimForAdcShVbufEn ( uint32_t  ui32Fcfg1Revision)

Returns the trim value from FCFG1 to be used as ADC_SH_VBUF_EN setting.

Parameters
ui32Fcfg1Revisionis the value of the FCFG1_O_FCFG1_REVISION register
Returns
Returns the trim value from FCFG1.

Referenced by SetupAfterColdResetWakeupFromShutDownCfg2().

743 {
744  uint32_t getTrimForAdcShVbufEnValue = 1; // Recommended default setting
745 
746  if ( ui32Fcfg1Revision >= 0x00000022 ) {
747  getTrimForAdcShVbufEnValue = ( HWREG( FCFG1_BASE + FCFG1_O_OSC_CONF ) &
748  FCFG1_OSC_CONF_ADC_SH_VBUF_EN_M ) >>
749  FCFG1_OSC_CONF_ADC_SH_VBUF_EN_S;
750  }
751 
752  return ( getTrimForAdcShVbufEnValue );
753 }

§ SetupGetTrimForAmpcompCtrl()

uint32_t SetupGetTrimForAmpcompCtrl ( uint32_t  ui32Fcfg1Revision)

Returns the trim value to be used for the AMPCOMP_CTRL register in OSC_DIG.

Parameters
ui32Fcfg1Revisionis the value of the FCFG1_O_FCFG1_REVISION register
Returns
Returns the trim value.

Referenced by SetupAfterColdResetWakeupFromShutDownCfg2().

623 {
624  uint32_t ui32TrimValue ;
625  uint32_t ui32Fcfg1Value ;
626  uint32_t ibiasOffset ;
627  uint32_t ibiasInit ;
628  uint32_t modeConf1 ;
629  int32_t deltaAdjust ;
630 
631  // Use device specific trim values located in factory configuration
632  // area. Register bit fields without trim values in the factory
633  // configuration area will be set to the value of 0.
634  ui32Fcfg1Value = HWREG( FCFG1_BASE + FCFG1_O_AMPCOMP_CTRL1 );
635 
636  ibiasOffset = ( ui32Fcfg1Value &
637  FCFG1_AMPCOMP_CTRL1_IBIAS_OFFSET_M ) >>
638  FCFG1_AMPCOMP_CTRL1_IBIAS_OFFSET_S ;
639  ibiasInit = ( ui32Fcfg1Value &
640  FCFG1_AMPCOMP_CTRL1_IBIAS_INIT_M ) >>
641  FCFG1_AMPCOMP_CTRL1_IBIAS_INIT_S ;
642 
643  if (( HWREG( CCFG_BASE + CCFG_O_SIZE_AND_DIS_FLAGS ) & CCFG_SIZE_AND_DIS_FLAGS_DIS_XOSC_OVR_M ) == 0 ) {
644  // Adjust with DELTA_IBIAS_OFFSET and DELTA_IBIAS_INIT from CCFG
645  modeConf1 = HWREG( CCFG_BASE + CCFG_O_MODE_CONF_1 );
646 
647  // Both fields are signed 4-bit values. This is an assumption when doing the sign extension.
648  deltaAdjust =
649  (((int32_t)( modeConf1 << ( 32 - CCFG_MODE_CONF_1_DELTA_IBIAS_OFFSET_W - CCFG_MODE_CONF_1_DELTA_IBIAS_OFFSET_S )))
650  >> ( 32 - CCFG_MODE_CONF_1_DELTA_IBIAS_OFFSET_W ));
651  deltaAdjust += (int32_t)ibiasOffset;
652  if ( deltaAdjust < 0 ) {
653  deltaAdjust = 0;
654  }
655  if ( deltaAdjust > ( DDI_0_OSC_AMPCOMPCTL_IBIAS_OFFSET_M >> DDI_0_OSC_AMPCOMPCTL_IBIAS_OFFSET_S )) {
656  deltaAdjust = ( DDI_0_OSC_AMPCOMPCTL_IBIAS_OFFSET_M >> DDI_0_OSC_AMPCOMPCTL_IBIAS_OFFSET_S );
657  }
658  ibiasOffset = (uint32_t)deltaAdjust;
659 
660  deltaAdjust =
661  (((int32_t)( modeConf1 << ( 32 - CCFG_MODE_CONF_1_DELTA_IBIAS_INIT_W - CCFG_MODE_CONF_1_DELTA_IBIAS_INIT_S )))
662  >> ( 32 - CCFG_MODE_CONF_1_DELTA_IBIAS_INIT_W ));
663  deltaAdjust += (int32_t)ibiasInit;
664  if ( deltaAdjust < 0 ) {
665  deltaAdjust = 0;
666  }
667  if ( deltaAdjust > ( DDI_0_OSC_AMPCOMPCTL_IBIAS_INIT_M >> DDI_0_OSC_AMPCOMPCTL_IBIAS_INIT_S )) {
668  deltaAdjust = ( DDI_0_OSC_AMPCOMPCTL_IBIAS_INIT_M >> DDI_0_OSC_AMPCOMPCTL_IBIAS_INIT_S );
669  }
670  ibiasInit = (uint32_t)deltaAdjust;
671  }
672  ui32TrimValue = ( ibiasOffset << DDI_0_OSC_AMPCOMPCTL_IBIAS_OFFSET_S ) |
673  ( ibiasInit << DDI_0_OSC_AMPCOMPCTL_IBIAS_INIT_S ) ;
674 
675  ui32TrimValue |= (((ui32Fcfg1Value &
676  FCFG1_AMPCOMP_CTRL1_LPM_IBIAS_WAIT_CNT_FINAL_M)>>
677  FCFG1_AMPCOMP_CTRL1_LPM_IBIAS_WAIT_CNT_FINAL_S)<<
678  DDI_0_OSC_AMPCOMPCTL_LPM_IBIAS_WAIT_CNT_FINAL_S);
679  ui32TrimValue |= (((ui32Fcfg1Value &
680  FCFG1_AMPCOMP_CTRL1_CAP_STEP_M)>>
681  FCFG1_AMPCOMP_CTRL1_CAP_STEP_S)<<
682  DDI_0_OSC_AMPCOMPCTL_CAP_STEP_S);
683  ui32TrimValue |= (((ui32Fcfg1Value &
684  FCFG1_AMPCOMP_CTRL1_IBIASCAP_HPTOLP_OL_CNT_M)>>
685  FCFG1_AMPCOMP_CTRL1_IBIASCAP_HPTOLP_OL_CNT_S)<<
686  DDI_0_OSC_AMPCOMPCTL_IBIASCAP_HPTOLP_OL_CNT_S);
687 
688  if ( ui32Fcfg1Revision >= 0x00000022 ) {
689  ui32TrimValue |= ((( ui32Fcfg1Value &
690  FCFG1_AMPCOMP_CTRL1_AMPCOMP_REQ_MODE_M ) >>
691  FCFG1_AMPCOMP_CTRL1_AMPCOMP_REQ_MODE_S ) <<
692  DDI_0_OSC_AMPCOMPCTL_AMPCOMP_REQ_MODE_S );
693  }
694 
695  return(ui32TrimValue);
696 }

§ SetupGetTrimForAmpcompTh1()

uint32_t SetupGetTrimForAmpcompTh1 ( void  )

Returns the trim value to be used for the AMPCOMP_TH1 register in OSC_DIG.

Returns
Returns the trim value.

Referenced by SetupAfterColdResetWakeupFromShutDownCfg2().

588 {
589  uint32_t ui32TrimValue;
590  uint32_t ui32Fcfg1Value;
591 
592  // Use device specific trim values located in factory configuration
593  // area. All defined register bit fields have a corresponding trim
594  // value in the factory configuration area
595  ui32Fcfg1Value = HWREG(FCFG1_BASE + FCFG1_O_AMPCOMP_TH1);
596  ui32TrimValue = (((ui32Fcfg1Value &
597  FCFG1_AMPCOMP_TH1_HPMRAMP3_LTH_M)>>
598  FCFG1_AMPCOMP_TH1_HPMRAMP3_LTH_S)<<
599  DDI_0_OSC_AMPCOMPTH1_HPMRAMP3_LTH_S);
600  ui32TrimValue |= (((ui32Fcfg1Value &
601  FCFG1_AMPCOMP_TH1_HPMRAMP3_HTH_M)>>
602  FCFG1_AMPCOMP_TH1_HPMRAMP3_HTH_S)<<
603  DDI_0_OSC_AMPCOMPTH1_HPMRAMP3_HTH_S);
604  ui32TrimValue |= (((ui32Fcfg1Value &
605  FCFG1_AMPCOMP_TH1_IBIASCAP_LPTOHP_OL_CNT_M)>>
606  FCFG1_AMPCOMP_TH1_IBIASCAP_LPTOHP_OL_CNT_S)<<
607  DDI_0_OSC_AMPCOMPTH1_IBIASCAP_LPTOHP_OL_CNT_S);
608  ui32TrimValue |= (((ui32Fcfg1Value &
609  FCFG1_AMPCOMP_TH1_HPMRAMP1_TH_M)>>
610  FCFG1_AMPCOMP_TH1_HPMRAMP1_TH_S)<<
611  DDI_0_OSC_AMPCOMPTH1_HPMRAMP1_TH_S);
612 
613  return(ui32TrimValue);
614 }

§ SetupGetTrimForAmpcompTh2()

uint32_t SetupGetTrimForAmpcompTh2 ( void  )

Returns the trim value to be used for the AMPCOMP_TH2 register in OSC_DIG.

Returns
Returns the trim value.

Referenced by SetupAfterColdResetWakeupFromShutDownCfg2().

553 {
554  uint32_t ui32TrimValue;
555  uint32_t ui32Fcfg1Value;
556 
557  // Use device specific trim value located in factory configuration
558  // area. All defined register bit fields have corresponding trim
559  // value in the factory configuration area
560  ui32Fcfg1Value = HWREG(FCFG1_BASE + FCFG1_O_AMPCOMP_TH2);
561  ui32TrimValue = ((ui32Fcfg1Value &
562  FCFG1_AMPCOMP_TH2_LPMUPDATE_LTH_M)>>
563  FCFG1_AMPCOMP_TH2_LPMUPDATE_LTH_S)<<
564  DDI_0_OSC_AMPCOMPTH2_LPMUPDATE_LTH_S;
565  ui32TrimValue |= (((ui32Fcfg1Value &
566  FCFG1_AMPCOMP_TH2_LPMUPDATE_HTM_M)>>
567  FCFG1_AMPCOMP_TH2_LPMUPDATE_HTM_S)<<
568  DDI_0_OSC_AMPCOMPTH2_LPMUPDATE_HTH_S);
569  ui32TrimValue |= (((ui32Fcfg1Value &
570  FCFG1_AMPCOMP_TH2_ADC_COMP_AMPTH_LPM_M)>>
571  FCFG1_AMPCOMP_TH2_ADC_COMP_AMPTH_LPM_S)<<
572  DDI_0_OSC_AMPCOMPTH2_ADC_COMP_AMPTH_LPM_S);
573  ui32TrimValue |= (((ui32Fcfg1Value &
574  FCFG1_AMPCOMP_TH2_ADC_COMP_AMPTH_HPM_M)>>
575  FCFG1_AMPCOMP_TH2_ADC_COMP_AMPTH_HPM_S)<<
576  DDI_0_OSC_AMPCOMPTH2_ADC_COMP_AMPTH_HPM_S);
577 
578  return(ui32TrimValue);
579 }

§ SetupGetTrimForAnabypassValue1()

uint32_t SetupGetTrimForAnabypassValue1 ( uint32_t  ccfg_ModeConfReg)

Returns the trim value to be used for the ANABYPASS_VALUE1 register in OSC_DIG.

Parameters
ccfg_ModeConfRegis the value of the CCFG_O_MODE_CONF_1 register
Returns
Returns the trim value.

Referenced by OSC_AdjustXoscHfCapArray(), and SetupAfterColdResetWakeupFromShutDownCfg2().

437 {
438  uint32_t ui32Fcfg1Value ;
439  uint32_t ui32XoscHfRow ;
440  uint32_t ui32XoscHfCol ;
441  uint32_t ui32TrimValue ;
442 
443  // Use device specific trim values located in factory configuration
444  // area for the XOSC_HF_COLUMN_Q12 and XOSC_HF_ROW_Q12 bit fields in
445  // the ANABYPASS_VALUE1 register. Value for the other bit fields
446  // are set to 0.
447 
448  ui32Fcfg1Value = HWREG(FCFG1_BASE + FCFG1_O_CONFIG_OSC_TOP);
449  ui32XoscHfRow = (( ui32Fcfg1Value &
450  FCFG1_CONFIG_OSC_TOP_XOSC_HF_ROW_Q12_M ) >>
451  FCFG1_CONFIG_OSC_TOP_XOSC_HF_ROW_Q12_S );
452  ui32XoscHfCol = (( ui32Fcfg1Value &
453  FCFG1_CONFIG_OSC_TOP_XOSC_HF_COLUMN_Q12_M ) >>
454  FCFG1_CONFIG_OSC_TOP_XOSC_HF_COLUMN_Q12_S );
455 
456  if (( ccfg_ModeConfReg & CCFG_MODE_CONF_XOSC_CAP_MOD ) == 0 ) {
457  // XOSC_CAP_MOD = 0 means: CAP_ARRAY_DELTA is in use -> Apply compensation
458  // XOSC_CAPARRAY_DELTA is located in bit[15:8] of ccfg_ModeConfReg
459  // Note: HW_REV_DEPENDENT_IMPLEMENTATION. Field width is not given by
460  // a define and sign extension must therefore be hard coded.
461  // ( A small test program is created verifying the code lines below:
462  // Ref.: ..\test\small_standalone_test_programs\CapArrayDeltaAdjust_test.c)
463  int32_t i32CustomerDeltaAdjust =
464  (((int32_t)( ccfg_ModeConfReg << ( 32 - CCFG_MODE_CONF_XOSC_CAPARRAY_DELTA_W - CCFG_MODE_CONF_XOSC_CAPARRAY_DELTA_S )))
465  >> ( 32 - CCFG_MODE_CONF_XOSC_CAPARRAY_DELTA_W ));
466 
467  while ( i32CustomerDeltaAdjust < 0 ) {
468  ui32XoscHfCol >>= 1; // COL 1 step down
469  if ( ui32XoscHfCol == 0 ) { // if COL below minimum
470  ui32XoscHfCol = 0xFFFF; // Set COL to maximum
471  ui32XoscHfRow >>= 1; // ROW 1 step down
472  if ( ui32XoscHfRow == 0 ) { // if ROW below minimum
473  ui32XoscHfRow = 1; // Set both ROW and COL
474  ui32XoscHfCol = 1; // to minimum
475  }
476  }
477  i32CustomerDeltaAdjust++;
478  }
479  while ( i32CustomerDeltaAdjust > 0 ) {
480  ui32XoscHfCol = ( ui32XoscHfCol << 1 ) | 1; // COL 1 step up
481  if ( ui32XoscHfCol > 0xFFFF ) { // if COL above maximum
482  ui32XoscHfCol = 1; // Set COL to minimum
483  ui32XoscHfRow = ( ui32XoscHfRow << 1 ) | 1; // ROW 1 step up
484  if ( ui32XoscHfRow > 0xF ) { // if ROW above maximum
485  ui32XoscHfRow = 0xF; // Set both ROW and COL
486  ui32XoscHfCol = 0xFFFF; // to maximum
487  }
488  }
489  i32CustomerDeltaAdjust--;
490  }
491  }
492 
493  ui32TrimValue = (( ui32XoscHfRow << DDI_0_OSC_ANABYPASSVAL1_XOSC_HF_ROW_Q12_S ) |
494  ( ui32XoscHfCol << DDI_0_OSC_ANABYPASSVAL1_XOSC_HF_COLUMN_Q12_S ) );
495 
496  return (ui32TrimValue);
497 }

§ SetupGetTrimForDblrLoopFilterResetVoltage()

uint32_t SetupGetTrimForDblrLoopFilterResetVoltage ( uint32_t  ui32Fcfg1Revision)

Returns the trim value from FCFG1 to be used as DBLR_LOOP_FILTER_RESET_VOLTAGE setting.

Parameters
ui32Fcfg1Revisionis the value of the FCFG1_O_FCFG1_REVISION register
Returns
Returns the trim value from FCFG1.

Referenced by SetupAfterColdResetWakeupFromShutDownCfg2().

705 {
706  uint32_t dblrLoopFilterResetVoltageValue = 0; // Reset value
707 
708  if ( ui32Fcfg1Revision >= 0x00000020 ) {
709  dblrLoopFilterResetVoltageValue = ( HWREG( FCFG1_BASE + FCFG1_O_MISC_OTP_DATA_1 ) &
710  FCFG1_MISC_OTP_DATA_1_DBLR_LOOP_FILTER_RESET_VOLTAGE_M ) >>
711  FCFG1_MISC_OTP_DATA_1_DBLR_LOOP_FILTER_RESET_VOLTAGE_S;
712  }
713 
714  return ( dblrLoopFilterResetVoltageValue );
715 }

§ SetupGetTrimForRadcExtCfg()

uint32_t SetupGetTrimForRadcExtCfg ( uint32_t  ui32Fcfg1Revision)

Returns the trim value to be used for the RADCEXTCFG register in OSC_DIG.

Parameters
ui32Fcfg1Revisionis the value of the FCFG1_O_FCFG1_REVISION register
Returns
Returns the trim value.

Referenced by SetupAfterColdResetWakeupFromShutDownCfg2().

812 {
813  uint32_t getTrimForRadcExtCfgValue = 0x403F8000; // Recommended default setting
814  uint32_t fcfg1Data;
815 
816  if ( ui32Fcfg1Revision >= 0x00000020 ) {
817  fcfg1Data = HWREG( FCFG1_BASE + FCFG1_O_MISC_OTP_DATA_1 );
818  getTrimForRadcExtCfgValue =
819  ( ( ( fcfg1Data & FCFG1_MISC_OTP_DATA_1_HPM_IBIAS_WAIT_CNT_M ) >>
820  FCFG1_MISC_OTP_DATA_1_HPM_IBIAS_WAIT_CNT_S ) <<
821  DDI_0_OSC_RADCEXTCFG_HPM_IBIAS_WAIT_CNT_S);
822 
823  getTrimForRadcExtCfgValue |=
824  ( ( ( fcfg1Data & FCFG1_MISC_OTP_DATA_1_LPM_IBIAS_WAIT_CNT_M ) >>
825  FCFG1_MISC_OTP_DATA_1_LPM_IBIAS_WAIT_CNT_S ) <<
826  DDI_0_OSC_RADCEXTCFG_LPM_IBIAS_WAIT_CNT_S);
827 
828  getTrimForRadcExtCfgValue |=
829  ( ( ( fcfg1Data & FCFG1_MISC_OTP_DATA_1_IDAC_STEP_M ) >>
830  FCFG1_MISC_OTP_DATA_1_IDAC_STEP_S ) <<
831  DDI_0_OSC_RADCEXTCFG_IDAC_STEP_S);
832  }
833 
834  return ( getTrimForRadcExtCfgValue );
835 }

§ SetupGetTrimForRcOscLfIBiasTrim()

uint32_t SetupGetTrimForRcOscLfIBiasTrim ( uint32_t  ui32Fcfg1Revision)

Returns the FCFG1 OSC_CONF_ATESTLF_RCOSCLF_IBIAS_TRIM.

Parameters
ui32Fcfg1Revisionis the value of the FCFG1_O_FCFG1_REVISION register
Returns
Returns the trim value from FCFG1.

Referenced by SetupAfterColdResetWakeupFromShutDownCfg2().

844 {
845  uint32_t trimForRcOscLfIBiasTrimValue = 0; // Default value
846 
847  if ( ui32Fcfg1Revision >= 0x00000022 ) {
848  trimForRcOscLfIBiasTrimValue = ( HWREG( FCFG1_BASE + FCFG1_O_OSC_CONF ) &
849  FCFG1_OSC_CONF_ATESTLF_RCOSCLF_IBIAS_TRIM_M ) >>
850  FCFG1_OSC_CONF_ATESTLF_RCOSCLF_IBIAS_TRIM_S ;
851  }
852 
853  return ( trimForRcOscLfIBiasTrimValue );
854 }

§ SetupGetTrimForRcOscLfRtuneCtuneTrim()

uint32_t SetupGetTrimForRcOscLfRtuneCtuneTrim ( void  )

Returns the trim value to be used for the RCOSCLF_RTUNE_TRIM and the RCOSCLF_CTUNE_TRIM bit fields in the XOSCLF_RCOSCLF_CTRL register in OSC_DIG.

Returns
Returns the trim value.

Referenced by SetupAfterColdResetWakeupFromShutDownCfg2().

506 {
507  uint32_t ui32TrimValue;
508 
509  // Use device specific trim values located in factory configuration
510  // area
511  ui32TrimValue =
512  ((HWREG(FCFG1_BASE + FCFG1_O_CONFIG_OSC_TOP) &
513  FCFG1_CONFIG_OSC_TOP_RCOSCLF_CTUNE_TRIM_M)>>
514  FCFG1_CONFIG_OSC_TOP_RCOSCLF_CTUNE_TRIM_S)<<
515  DDI_0_OSC_LFOSCCTL_RCOSCLF_CTUNE_TRIM_S;
516 
517  ui32TrimValue |=
518  ((HWREG(FCFG1_BASE + FCFG1_O_CONFIG_OSC_TOP) &
519  FCFG1_CONFIG_OSC_TOP_RCOSCLF_RTUNE_TRIM_M)>>
520  FCFG1_CONFIG_OSC_TOP_RCOSCLF_RTUNE_TRIM_S)<<
521  DDI_0_OSC_LFOSCCTL_RCOSCLF_RTUNE_TRIM_S;
522 
523  return(ui32TrimValue);
524 }

§ SetupGetTrimForXoscHfCtl()

uint32_t SetupGetTrimForXoscHfCtl ( uint32_t  ui32Fcfg1Revision)

Returns the trim value to be used for the XOSCHFCTL register in OSC_DIG.

Parameters
ui32Fcfg1Revisionis the value of the FCFG1_O_FCFG1_REVISION register
Returns
Returns the trim value.

Referenced by SetupAfterColdResetWakeupFromShutDownCfg2().

762 {
763  uint32_t getTrimForXoschfCtlValue = 0; // Recommended default setting
764  uint32_t fcfg1Data;
765 
766  if ( ui32Fcfg1Revision >= 0x00000020 ) {
767  fcfg1Data = HWREG( FCFG1_BASE + FCFG1_O_MISC_OTP_DATA_1 );
768  getTrimForXoschfCtlValue =
769  ( ( ( fcfg1Data & FCFG1_MISC_OTP_DATA_1_PEAK_DET_ITRIM_M ) >>
770  FCFG1_MISC_OTP_DATA_1_PEAK_DET_ITRIM_S ) <<
771  DDI_0_OSC_XOSCHFCTL_PEAK_DET_ITRIM_S);
772 
773  getTrimForXoschfCtlValue |=
774  ( ( ( fcfg1Data & FCFG1_MISC_OTP_DATA_1_HP_BUF_ITRIM_M ) >>
775  FCFG1_MISC_OTP_DATA_1_HP_BUF_ITRIM_S ) <<
776  DDI_0_OSC_XOSCHFCTL_HP_BUF_ITRIM_S);
777 
778  getTrimForXoschfCtlValue |=
779  ( ( ( fcfg1Data & FCFG1_MISC_OTP_DATA_1_LP_BUF_ITRIM_M ) >>
780  FCFG1_MISC_OTP_DATA_1_LP_BUF_ITRIM_S ) <<
781  DDI_0_OSC_XOSCHFCTL_LP_BUF_ITRIM_S);
782  }
783 
784  return ( getTrimForXoschfCtlValue );
785 }

§ SetupGetTrimForXoscHfFastStart()

uint32_t SetupGetTrimForXoscHfFastStart ( void  )

Returns the trim value to be used as OSC_DIG:CTL1.XOSC_HF_FAST_START.

Returns
Returns the trim value.

Referenced by SetupAfterColdResetWakeupFromShutDownCfg3().

794 {
795  uint32_t ui32XoscHfFastStartValue ;
796 
797  // Get value from FCFG1
798  ui32XoscHfFastStartValue = ( HWREG( FCFG1_BASE + FCFG1_O_OSC_CONF ) &
799  FCFG1_OSC_CONF_XOSC_HF_FAST_START_M ) >>
800  FCFG1_OSC_CONF_XOSC_HF_FAST_START_S;
801 
802  return ( ui32XoscHfFastStartValue );
803 }

§ SetupGetTrimForXoscHfIbiastherm()

uint32_t SetupGetTrimForXoscHfIbiastherm ( void  )

Returns the trim value to be used for the XOSC_HF_IBIASTHERM bit field in the ANABYPASS_VALUE2 register in OSC_DIG.

Returns
Returns the trim value.

Referenced by SetupAfterColdResetWakeupFromShutDownCfg2().

533 {
534  uint32_t ui32TrimValue;
535 
536  // Use device specific trim value located in factory configuration
537  // area
538  ui32TrimValue =
539  (HWREG(FCFG1_BASE + FCFG1_O_ANABYPASS_VALUE2) &
540  FCFG1_ANABYPASS_VALUE2_XOSC_HF_IBIASTHERM_M)>>
541  FCFG1_ANABYPASS_VALUE2_XOSC_HF_IBIASTHERM_S;
542 
543  return(ui32TrimValue);
544 }

§ SetupGetTrimForXoscLfRegulatorAndCmirrwrRatio()

uint32_t SetupGetTrimForXoscLfRegulatorAndCmirrwrRatio ( uint32_t  ui32Fcfg1Revision)

Returns XOSCLF_REGULATOR_TRIM and XOSCLF_CMIRRWR_RATIO as one packet spanning bits [5:0] in the returned value.

Parameters
ui32Fcfg1Revisionis the value of the FCFG1_O_FCFG1_REVISION register
Returns
Returns XOSCLF_REGULATOR_TRIM and XOSCLF_CMIRRWR_RATIO as one packet.

Referenced by SetupAfterColdResetWakeupFromShutDownCfg2().

863 {
864  uint32_t trimForXoscLfRegulatorAndCmirrwrRatioValue = 0; // Default value for both fields
865 
866  if ( ui32Fcfg1Revision >= 0x00000022 ) {
867  trimForXoscLfRegulatorAndCmirrwrRatioValue = ( HWREG( FCFG1_BASE + FCFG1_O_OSC_CONF ) &
868  ( FCFG1_OSC_CONF_XOSCLF_REGULATOR_TRIM_M |
869  FCFG1_OSC_CONF_XOSCLF_CMIRRWR_RATIO_M )) >>
870  FCFG1_OSC_CONF_XOSCLF_CMIRRWR_RATIO_S ;
871  }
872 
873  return ( trimForXoscLfRegulatorAndCmirrwrRatioValue );
874 }

§ SetupSetAonRtcSubSecInc()

void SetupSetAonRtcSubSecInc ( uint32_t  subSecInc)

Doing the tricky stuff needed to enter new RTCSUBSECINC value.

Parameters
subSecInc
Returns
None

Referenced by OSC_HPOSCRtcCompensate(), SetupAfterColdResetWakeupFromShutDownCfg3(), SetupSignExtendVddrTrimValue(), and SetupTrimDevice().

928 {
929  // Loading a new RTCSUBSECINC value is done in 5 steps:
930  // 1. Write bit[15:0] of new SUBSECINC value to AUX_SYSIF_O_RTCSUBSECINC0
931  // 2. Write bit[23:16] of new SUBSECINC value to AUX_SYSIF_O_RTCSUBSECINC1
932  // 3. Set AUX_SYSIF_RTCSUBSECINCCTL_UPD_REQ
933  // 4. Wait for AUX_SYSIF_RTCSUBSECINCCTL_UPD_ACK
934  // 5. Clear AUX_SYSIF_RTCSUBSECINCCTL_UPD_REQ
935  HWREG( AUX_SYSIF_BASE + AUX_SYSIF_O_RTCSUBSECINC0 ) = (( subSecInc ) & AUX_SYSIF_RTCSUBSECINC0_INC15_0_M );
936  HWREG( AUX_SYSIF_BASE + AUX_SYSIF_O_RTCSUBSECINC1 ) = (( subSecInc >> 16 ) & AUX_SYSIF_RTCSUBSECINC1_INC23_16_M );
937 
938  HWREG( AUX_SYSIF_BASE + AUX_SYSIF_O_RTCSUBSECINCCTL ) = AUX_SYSIF_RTCSUBSECINCCTL_UPD_REQ;
939  while( ! ( HWREGBITW( AUX_SYSIF_BASE + AUX_SYSIF_O_RTCSUBSECINCCTL, AUX_SYSIF_RTCSUBSECINCCTL_UPD_ACK_BITN )));
940  HWREG( AUX_SYSIF_BASE + AUX_SYSIF_O_RTCSUBSECINCCTL ) = 0;
941 
942 }

§ SetupSetCacheModeAccordingToCcfgSetting()

void SetupSetCacheModeAccordingToCcfgSetting ( void  )

Set correct VIMS_MODE according to CCFG setting (CACHE or GPRAM)

Returns
None

Referenced by SetupSignExtendVddrTrimValue(), and SetupTrimDevice().

883 {
884  // - Make sure to enable aggressive VIMS clock gating for power optimization
885  // Only for PG2 devices.
886  // - Enable cache prefetch enable as default setting
887  // (Slightly higher power consumption, but higher CPU performance)
888  // - IF ( CCFG_..._DIS_GPRAM == 1 )
889  // then: Enable cache (set cache mode = 1), even if set by ROM boot code
890  // (This is done because it's not set by boot code when running inside
891  // a debugger supporting the Halt In Boot (HIB) functionality).
892  // else: Set MODE_GPRAM if not already set (see inline comments as well)
893  uint32_t vimsCtlMode0 ;
894 
895  while ( HWREGBITW( VIMS_BASE + VIMS_O_STAT, VIMS_STAT_MODE_CHANGING_BITN )) {
896  // Do nothing - wait for an eventual ongoing mode change to complete.
897  // (There should typically be no wait time here, but need to be sure)
898  }
899 
900  // Note that Mode=0 is equal to MODE_GPRAM
901  vimsCtlMode0 = (( HWREG( VIMS_BASE + VIMS_O_CTL ) & ~VIMS_CTL_MODE_M ) | VIMS_CTL_DYN_CG_EN_M | VIMS_CTL_PREF_EN_M );
902 
903 
904  if ( HWREG( CCFG_BASE + CCFG_O_SIZE_AND_DIS_FLAGS ) & CCFG_SIZE_AND_DIS_FLAGS_DIS_GPRAM ) {
905  // Enable cache (and hence disable GPRAM)
906  HWREG( VIMS_BASE + VIMS_O_CTL ) = ( vimsCtlMode0 | VIMS_CTL_MODE_CACHE );
907  } else if (( HWREG( VIMS_BASE + VIMS_O_STAT ) & VIMS_STAT_MODE_M ) != VIMS_STAT_MODE_GPRAM ) {
908  // GPRAM is enabled in CCFG but not selected
909  // Note: It is recommended to go via MODE_OFF when switching to MODE_GPRAM
910  HWREG( VIMS_BASE + VIMS_O_CTL ) = ( vimsCtlMode0 | VIMS_CTL_MODE_OFF );
911  while (( HWREG( VIMS_BASE + VIMS_O_STAT ) & VIMS_STAT_MODE_M ) != VIMS_STAT_MODE_OFF ) {
912  // Do nothing - wait for an eventual mode change to complete (This goes fast).
913  }
914  HWREG( VIMS_BASE + VIMS_O_CTL ) = vimsCtlMode0;
915  } else {
916  // Correct mode, but make sure PREF_EN and DYN_CG_EN always are set
917  HWREG( VIMS_BASE + VIMS_O_CTL ) = vimsCtlMode0;
918  }
919 }

§ SetupSignExtendVddrTrimValue()

static int32_t SetupSignExtendVddrTrimValue ( uint32_t  ui32VddrTrimVal)
inlinestatic

Sign extend the VDDR_TRIM setting (special format ranging from -10 to +21)

Parameters
ui32VddrTrimVal
Returns
Returns Sign extended VDDR_TRIM setting.

Referenced by SetupStepVddrTrimTo().

316 {
317  // The VDDR trim value is 5 bits representing the range from -10 to +21
318  // (where -10=0x16, -1=0x1F, 0=0x00, 1=0x01 and +21=0x15)
319  int32_t i32SignedVddrVal = ui32VddrTrimVal;
320  if ( i32SignedVddrVal > 0x15 ) {
321  i32SignedVddrVal -= 0x20;
322  }
323  return ( i32SignedVddrVal );
324 }
Here is the call graph for this function:

§ SetupStepVddrTrimTo()

void SetupStepVddrTrimTo ( uint32_t  toCode)

Set VDDR boost mode (by setting VDDR_TRIM to FCFG1..VDDR_TRIM_HH and setting VDDS_BOD to max)

Parameters
toCodespecifies the target VDDR trim value. The input parameter toCode can be either the signed extended trim value or holding the trim code bits only.
Returns
None

Referenced by SetupAfterColdResetWakeupFromShutDownCfg1(), and SetupSignExtendVddrTrimValue().

119 {
120  uint32_t pmctlResetctl_reg ;
121  int32_t targetTrim ;
122  int32_t currentTrim ;
123 
124  targetTrim = SetupSignExtendVddrTrimValue( toCode & ( ADI_3_REFSYS_DCDCCTL0_VDDR_TRIM_M >> ADI_3_REFSYS_DCDCCTL0_VDDR_TRIM_S ));
125  currentTrim = SetupSignExtendVddrTrimValue((
126  HWREGB( ADI3_BASE + ADI_3_REFSYS_O_DCDCCTL0 ) &
127  ADI_3_REFSYS_DCDCCTL0_VDDR_TRIM_M ) >>
128  ADI_3_REFSYS_DCDCCTL0_VDDR_TRIM_S ) ;
129 
130  if ( targetTrim != currentTrim ) {
131  pmctlResetctl_reg = ( HWREG( AON_PMCTL_BASE + AON_PMCTL_O_RESETCTL ) & ~AON_PMCTL_RESETCTL_MCU_WARM_RESET_M );
132  if ( pmctlResetctl_reg & AON_PMCTL_RESETCTL_VDDR_LOSS_EN_M ) {
133  HWREG( AON_PMCTL_BASE + AON_PMCTL_O_RESETCTL ) = ( pmctlResetctl_reg & ~AON_PMCTL_RESETCTL_VDDR_LOSS_EN_M );
134  HWREG( AON_RTC_BASE + AON_RTC_O_SYNC ); // Wait for VDDR_LOSS_EN setting to propagate
135  }
136 
137  while ( targetTrim != currentTrim ) {
138  HWREG( AON_RTC_BASE + AON_RTC_O_SYNCLF ); // Wait for next edge on SCLK_LF (positive or negative)
139 
140  if ( targetTrim > currentTrim ) currentTrim++;
141  else currentTrim--;
142 
143  HWREGB( ADI3_BASE + ADI_3_REFSYS_O_DCDCCTL0 ) = (
144  ( HWREGB( ADI3_BASE + ADI_3_REFSYS_O_DCDCCTL0 ) & ~ADI_3_REFSYS_DCDCCTL0_VDDR_TRIM_M ) |
145  ((((uint32_t)currentTrim) << ADI_3_REFSYS_DCDCCTL0_VDDR_TRIM_S ) &
146  ADI_3_REFSYS_DCDCCTL0_VDDR_TRIM_M ) );
147  }
148 
149  HWREG( AON_RTC_BASE + AON_RTC_O_SYNCLF ); // Wait for next edge on SCLK_LF (positive or negative)
150 
151  if ( pmctlResetctl_reg & AON_PMCTL_RESETCTL_VDDR_LOSS_EN_M ) {
152  HWREG( AON_RTC_BASE + AON_RTC_O_SYNCLF ); // Wait for next edge on SCLK_LF (positive or negative)
153  HWREG( AON_RTC_BASE + AON_RTC_O_SYNCLF ); // Wait for next edge on SCLK_LF (positive or negative)
154  HWREG( AON_PMCTL_BASE + AON_PMCTL_O_RESETCTL ) = pmctlResetctl_reg;
155  HWREG( AON_RTC_BASE + AON_RTC_O_SYNC ); // And finally wait for VDDR_LOSS_EN setting to propagate
156  }
157  }
158 }
static int32_t SetupSignExtendVddrTrimValue(uint32_t ui32VddrTrimVal)
Sign extend the VDDR_TRIM setting (special format ranging from -10 to +21)
Definition: setup_rom.h:315
Here is the call graph for this function: