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

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

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

118 {
119  int32_t i32VddrSleepTrim;
120  int32_t i32VddrSleepDelta;
121 
122  {
123  i32VddrSleepTrim = SetupSignExtendVddrTrimValue((
124  HWREG( FCFG1_BASE + FCFG1_O_LDO_TRIM ) &
127  }
128 
129  // Adjust the VDDR_TRIM_SLEEP value with value adjustable by customer (CCFG_MODE_CONF_VDDR_TRIM_SLEEP_DELTA)
130  // Read and sign extend VddrSleepDelta (in range -8 to +7)
131  i32VddrSleepDelta =
132  (((int32_t)( ccfg_ModeConfReg << ( 32 - CCFG_MODE_CONF_VDDR_TRIM_SLEEP_DELTA_W - CCFG_MODE_CONF_VDDR_TRIM_SLEEP_DELTA_S )))
134  // Calculate new VDDR sleep trim
135  i32VddrSleepTrim = ( i32VddrSleepTrim + i32VddrSleepDelta + 1 );
136  if ( i32VddrSleepTrim > 21 ) i32VddrSleepTrim = 21;
137  if ( i32VddrSleepTrim < -10 ) i32VddrSleepTrim = -10;
138  // Write adjusted value using MASKED write (MASK8)
139  HWREGH( ADI3_BASE + ADI_O_MASK8B + ( ADI_3_REFSYS_O_DCDCCTL1 * 2 )) = (( ADI_3_REFSYS_DCDCCTL1_VDDR_TRIM_SLEEP_M << 8 ) |
141 
142  // 1.
143  // Do not allow DCDC to be enabled if in external regulator mode.
144  // Preventing this by setting both the RECHARGE and the ACTIVE bits bit in the CCFG_MODE_CONF copy register (ccfg_ModeConfReg).
145  //
146  // 2.
147  // Adjusted battery monitor low limit in internal regulator mode.
148  // This is done by setting AON_BATMON_FLASHPUMPP0_LOWLIM=0 in internal regulator mode.
151  } else {
153  }
154 
155  // set the RECHARGE source based upon CCFG:MODE_CONF:DCDC_RECHARGE
156  // Note: Inverse polarity
158  ((( ccfg_ModeConfReg >> CCFG_MODE_CONF_DCDC_RECHARGE_S ) & 1 ) ^ 1 );
159 
160  // set the ACTIVE source based upon CCFG:MODE_CONF:DCDC_ACTIVE
161  // Note: Inverse polarity
163  ((( ccfg_ModeConfReg >> CCFG_MODE_CONF_DCDC_ACTIVE_S ) & 1 ) ^ 1 );
164 }
static int32_t SetupSignExtendVddrTrimValue(uint32_t ui32VddrTrimVal)
Sign extend the VDDR_TRIM setting (special format ranging from -10 to +21)
Definition: setup_rom.h:316

Here is the call graph for this function:

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

173 {
174  uint32_t ui32Trim;
175 
176  // Following sequence is required for using XOSCHF, if not included
177  // devices crashes when trying to switch to XOSCHF.
178  //
179  // Trim CAP settings. Get and set trim value for the ANABYPASS_VALUE1
180  // register
181  ui32Trim = SetupGetTrimForAnabypassValue1( ccfg_ModeConfReg );
183 
184  // Trim RCOSC_LF. Get and set trim values for the RCOSCLF_RTUNE_TRIM and
185  // RCOSCLF_CTUNE_TRIM fields in the XOSCLF_RCOSCLF_CTRL register.
191  ui32Trim);
192 
193  // Trim XOSCHF IBIAS THERM. Get and set trim value for the
194  // XOSCHF IBIAS THERM bit field in the ANABYPASS_VALUE2 register. Other
195  // register bit fields are set to 0.
196  ui32Trim = SetupGetTrimForXoscHfIbiastherm();
199 
200  // Trim AMPCOMP settings required before switch to XOSCHF
201  ui32Trim = SetupGetTrimForAmpcompTh2();
203  ui32Trim = SetupGetTrimForAmpcompTh1();
205 #if ( CCFG_BASE == CCFG_BASE_DEFAULT )
206  ui32Trim = SetupGetTrimForAmpcompCtrl( ui32Fcfg1Revision );
207 #else
208  ui32Trim = NOROM_SetupGetTrimForAmpcompCtrl( ui32Fcfg1Revision );
209 #endif
211 
212  // Set trim for DDI_0_OSC_ADCDOUBLERNANOAMPCTL_ADC_SH_MODE_EN in accordance to FCFG1 setting
213  // This is bit[5] in the DDI_0_OSC_O_ADCDOUBLERNANOAMPCTL register
214  // Using MASK4 write + 1 => writing to bits[7:4]
215  ui32Trim = SetupGetTrimForAdcShModeEn( ui32Fcfg1Revision );
216  HWREGB( AUX_DDI0_OSC_BASE + DDI_O_MASK4B + ( DDI_0_OSC_O_ADCDOUBLERNANOAMPCTL * 2 ) + 1 ) =
217  ( 0x20 | ( ui32Trim << 1 ));
218 
219  // Set trim for DDI_0_OSC_ADCDOUBLERNANOAMPCTL_ADC_SH_VBUF_EN in accordance to FCFG1 setting
220  // This is bit[4] in the DDI_0_OSC_O_ADCDOUBLERNANOAMPCTL register
221  // Using MASK4 write + 1 => writing to bits[7:4]
222  ui32Trim = SetupGetTrimForAdcShVbufEn( ui32Fcfg1Revision );
223  HWREGB( AUX_DDI0_OSC_BASE + DDI_O_MASK4B + ( DDI_0_OSC_O_ADCDOUBLERNANOAMPCTL * 2 ) + 1 ) =
224  ( 0x10 | ( ui32Trim ));
225 
226  // Set trim for the PEAK_DET_ITRIM, HP_BUF_ITRIM and LP_BUF_ITRIM bit fields
227  // in the DDI0_OSC_O_XOSCHFCTL register in accordance to FCFG1 setting.
228  // Remaining register bit fields are set to their reset values of 0.
229  ui32Trim = SetupGetTrimForXoscHfCtl(ui32Fcfg1Revision);
231 
232  // Set trim for DBLR_LOOP_FILTER_RESET_VOLTAGE in accordance to FCFG1 setting
233  // (This is bits [18:17] in DDI_0_OSC_O_ADCDOUBLERNANOAMPCTL)
234  // (Using MASK4 write + 4 => writing to bits[19:16] => (4*4))
235  // (Assuming: DDI_0_OSC_ADCDOUBLERNANOAMPCTL_DBLR_LOOP_FILTER_RESET_VOLTAGE_S = 17 and
236  // that DDI_0_OSC_ADCDOUBLERNANOAMPCTL_DBLR_LOOP_FILTER_RESET_VOLTAGE_M = 0x00060000)
237  ui32Trim = SetupGetTrimForDblrLoopFilterResetVoltage( ui32Fcfg1Revision );
238  HWREGB( AUX_DDI0_OSC_BASE + DDI_O_MASK4B + ( DDI_0_OSC_O_ADCDOUBLERNANOAMPCTL * 2 ) + 4 ) =
239  ( 0x60 | ( ui32Trim << 1 ));
240 
241  // Update DDI_0_OSC_ATESTCTL_ATESTLF_RCOSCLF_IBIAS_TRIM with data from
243  // This is DDI_0_OSC_O_ATESTCTL bit[7]
244  // ( DDI_0_OSC_O_ATESTCTL is currently hidden (but=0x00000020))
245  // Using MASK4 write + 1 => writing to bits[7:4]
246  ui32Trim = SetupGetTrimForRcOscLfIBiasTrim( ui32Fcfg1Revision );
247  HWREGB( AUX_DDI0_OSC_BASE + DDI_O_MASK4B + ( 0x00000020 * 2 ) + 1 ) =
248  ( 0x80 | ( ui32Trim << 3 ));
249 
252  // This can be simplified since the registers are packed together in the same
253  // order both in FCFG1 and in the HW register.
254  // This spans DDI_0_OSC_O_LFOSCCTL bits[23:18]
255  // Using MASK8 write + 4 => writing to bits[23:16]
256  ui32Trim = SetupGetTrimForXoscLfRegulatorAndCmirrwrRatio( ui32Fcfg1Revision );
257  HWREGH( AUX_DDI0_OSC_BASE + DDI_O_MASK8B + ( DDI_0_OSC_O_LFOSCCTL * 2 ) + 4 ) =
258  ( 0xFC00 | ( ui32Trim << 2 ));
259 
260  // Set trim the HPM_IBIAS_WAIT_CNT, LPM_IBIAS_WAIT_CNT and IDAC_STEP bit
261  // fields in the DDI0_OSC_O_RADCEXTCFG register in accordance to FCFG1 setting.
262  // Remaining register bit fields are set to their reset values of 0.
263  ui32Trim = SetupGetTrimForRadcExtCfg(ui32Fcfg1Revision);
265 
266  // Setting FORCE_KICKSTART_EN (ref. CC26_V1_BUG00261). Should also be done for PG2
267  // (This is bit 22 in DDI_0_OSC_O_CTL0)
269 }
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:678
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:817
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
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:697
uint32_t SetupGetTrimForXoscHfCtl(uint32_t ui32Fcfg1Revision)
Returns the trim value to be used for the XOSCHFCTL register in OSC_DIG.
Definition: setup_rom.c:716
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:487
uint32_t SetupGetTrimForRadcExtCfg(uint32_t ui32Fcfg1Revision)
Returns the trim value to be used for the RADCEXTCFG register in OSC_DIG.
Definition: setup_rom.c:766
uint32_t SetupGetTrimForAnabypassValue1(uint32_t ccfg_ModeConfReg)
Returns the trim value to be used for the ANABYPASS_VALUE1 register in OSC_DIG.
Definition: setup_rom.c:391
uint32_t SetupGetTrimForRcOscLfIBiasTrim(uint32_t ui32Fcfg1Revision)
Returns the FCFG1 OSC_CONF_ATESTLF_RCOSCLF_IBIAS_TRIM.
Definition: setup_rom.c:798
uint32_t SetupGetTrimForAmpcompTh1(void)
Returns the trim value to be used for the AMPCOMP_TH1 register in OSC_DIG.
Definition: setup_rom.c:542
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:577
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
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:460
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:659
uint32_t SetupGetTrimForAmpcompTh2(void)
Returns the trim value to be used for the AMPCOMP_TH2 register in OSC_DIG.
Definition: setup_rom.c:507

Here is the call graph for this function:

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

278 {
279  uint32_t fcfg1OscConf;
280  uint32_t ui32Trim;
281  uint32_t currentHfClock;
282  uint32_t ccfgExtLfClk;
283 
284  // Examine the XOSC_FREQ field to select 0x1=HPOSC, 0x2=48MHz XOSC, 0x3=24MHz XOSC
285  switch (( ccfg_ModeConfReg & CCFG_MODE_CONF_XOSC_FREQ_M ) >> CCFG_MODE_CONF_XOSC_FREQ_S ) {
286  case 2 :
287  // XOSC source is a 48 MHz crystal
288  // Do nothing (since this is the reset setting)
289  break;
290  case 1 :
291  // XOSC source is HPOSC (trim the HPOSC if this is a chip with HPOSC, otherwise skip trimming and default to 24 MHz XOSC)
292 
293  fcfg1OscConf = HWREG( FCFG1_BASE + FCFG1_O_OSC_CONF );
294 
295  if (( fcfg1OscConf & FCFG1_OSC_CONF_HPOSC_OPTION ) == 0 ) {
296  // This is a HPOSC chip, apply HPOSC settings
297  // Set bit DDI_0_OSC_CTL0_HPOSC_MODE_EN (this is bit 14 in DDI_0_OSC_O_CTL0)
299 
307 
320  break;
321  }
322  // Not a HPOSC chip - fall through to default
323  default :
324  // XOSC source is a 24 MHz crystal (default)
325  // Set bit DDI_0_OSC_CTL0_XTAL_IS_24M (this is bit 31 in DDI_0_OSC_O_CTL0)
327  break;
328  }
329 
330  // Set XOSC_HF in bypass mode if CCFG is configured for external TCXO
331  // 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.
334  }
335 
336  // Clear DDI_0_OSC_CTL0_CLK_LOSS_EN (ClockLossEventEnable()). This is bit 9 in DDI_0_OSC_O_CTL0.
337  // This is typically already 0 except on Lizard where it is set in ROM-boot
339 
340  // Setting DDI_0_OSC_CTL1_XOSC_HF_FAST_START according to value found in FCFG1
341  ui32Trim = SetupGetTrimForXoscHfFastStart();
342  HWREGB( AUX_DDI0_OSC_BASE + DDI_O_MASK4B + ( DDI_0_OSC_O_CTL1 * 2 )) = ( 0x30 | ui32Trim );
343 
344  // setup the LF clock based upon CCFG:MODE_CONF:SCLK_LF_OPTION
345  switch (( ccfg_ModeConfReg & CCFG_MODE_CONF_SCLK_LF_OPTION_M ) >> CCFG_MODE_CONF_SCLK_LF_OPTION_S ) {
346  case 0 : // XOSC_HF_DLF (XOSCHF/1536) -> SCLK_LF (=31250 Hz)
348  SetupSetAonRtcSubSecInc( 0x8637BD ); // RTC_INCREMENT = 2^38 / frequency
349  break;
350  case 1 : // EXTERNAL signal -> SCLK_LF (frequency=2^38/CCFG_EXT_LF_CLK_RTC_INCREMENT)
351  // Set SCLK_LF to use the same source as SCLK_HF
352  // Can be simplified a bit since possible return values for HF matches LF settings
353  currentHfClock = OSCClockSourceGet( OSC_SRC_CLK_HF );
354  OSCClockSourceSet( OSC_SRC_CLK_LF, currentHfClock );
355  while( OSCClockSourceGet( OSC_SRC_CLK_LF ) != currentHfClock ) {
356  // Wait until switched
357  }
358  ccfgExtLfClk = HWREG( CCFG_BASE + CCFG_O_EXT_LF_CLK );
362  IOC_STD_INPUT | IOC_HYST_ENABLE ); // Route external clock to AON IOC w/hysteresis
363  // Set XOSC_LF in bypass mode to allow external 32 kHz clock
365  // Fall through to set XOSC_LF as SCLK_LF source
366  case 2 : // XOSC_LF -> SLCK_LF (32768 Hz)
368  break;
369  default : // (=3) RCOSC_LF
371  break;
372  }
373 
374  // Update ADI_4_AUX_ADCREF1_VTRIM with value from FCFG1
375  HWREGB( AUX_ADI4_BASE + ADI_4_AUX_O_ADCREF1 ) =
380 
381  // Sync with AON
382  SysCtrlAonSync();
383 }
static void SysCtrlAonSync(void)
Sync all accesses to the AON register interface.
Definition: sys_ctrl.h:177
#define IOC_PORT_AON_CLK32K
Definition: ioc.h:169
uint32_t OSCClockSourceGet(uint32_t ui32SrcClk)
Get the source clock settings.
Definition: osc.c:151
#define IOC_STD_INPUT
Definition: ioc.h:297
#define OSC_SRC_CLK_HF
Definition: osc.h:113
#define OSC_XOSC_HF
Definition: osc.h:118
#define OSC_SRC_CLK_LF
Definition: osc.h:115
void SetupSetAonRtcSubSecInc(uint32_t subSecInc)
Doing the tricky stuff needed to enter new RTCSUBSECINC value.
Definition: setup_rom.c:882
#define OSC_RCOSC_LF
Definition: osc.h:119
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:220
void OSCClockSourceSet(uint32_t ui32SrcClk, uint32_t ui32Osc)
Configure the oscillator input to the a source clock.
Definition: osc.c:104
uint32_t SetupGetTrimForXoscHfFastStart(void)
Returns the trim value to be used as OSC_DIG:CTL1.XOSC_HF_FAST_START.
Definition: setup_rom.c:748
#define OSC_XOSC_LF
Definition: osc.h:120

Here is the call graph for this function:

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

679 {
680  uint32_t getTrimForAdcShModeEnValue = 1; // Recommended default setting
681 
682  if ( ui32Fcfg1Revision >= 0x00000022 ) {
683  getTrimForAdcShModeEnValue = ( HWREG( FCFG1_BASE + FCFG1_O_OSC_CONF ) &
686  }
687 
688  return ( getTrimForAdcShModeEnValue );
689 }
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().

698 {
699  uint32_t getTrimForAdcShVbufEnValue = 1; // Recommended default setting
700 
701  if ( ui32Fcfg1Revision >= 0x00000022 ) {
702  getTrimForAdcShVbufEnValue = ( HWREG( FCFG1_BASE + FCFG1_O_OSC_CONF ) &
705  }
706 
707  return ( getTrimForAdcShVbufEnValue );
708 }
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().

578 {
579  uint32_t ui32TrimValue ;
580  uint32_t ui32Fcfg1Value ;
581  uint32_t ibiasOffset ;
582  uint32_t ibiasInit ;
583  uint32_t modeConf1 ;
584  int32_t deltaAdjust ;
585 
586  // Use device specific trim values located in factory configuration
587  // area. Register bit fields without trim values in the factory
588  // configuration area will be set to the value of 0.
589  ui32Fcfg1Value = HWREG( FCFG1_BASE + FCFG1_O_AMPCOMP_CTRL1 );
590 
591  ibiasOffset = ( ui32Fcfg1Value &
594  ibiasInit = ( ui32Fcfg1Value &
597 
599  // Adjust with DELTA_IBIAS_OFFSET and DELTA_IBIAS_INIT from CCFG
600  modeConf1 = HWREG( CCFG_BASE + CCFG_O_MODE_CONF_1 );
601 
602  // Both fields are signed 4-bit values. This is an assumption when doing the sign extension.
603  deltaAdjust =
606  deltaAdjust += (int32_t)ibiasOffset;
607  if ( deltaAdjust < 0 ) {
608  deltaAdjust = 0;
609  }
612  }
613  ibiasOffset = (uint32_t)deltaAdjust;
614 
615  deltaAdjust =
616  (((int32_t)( modeConf1 << ( 32 - CCFG_MODE_CONF_1_DELTA_IBIAS_INIT_W - CCFG_MODE_CONF_1_DELTA_IBIAS_INIT_S )))
618  deltaAdjust += (int32_t)ibiasInit;
619  if ( deltaAdjust < 0 ) {
620  deltaAdjust = 0;
621  }
624  }
625  ibiasInit = (uint32_t)deltaAdjust;
626  }
627  ui32TrimValue = ( ibiasOffset << DDI_0_OSC_AMPCOMPCTL_IBIAS_OFFSET_S ) |
628  ( ibiasInit << DDI_0_OSC_AMPCOMPCTL_IBIAS_INIT_S ) ;
629 
630  ui32TrimValue |= (((ui32Fcfg1Value &
634  ui32TrimValue |= (((ui32Fcfg1Value &
638  ui32TrimValue |= (((ui32Fcfg1Value &
642 
643  if ( ui32Fcfg1Revision >= 0x00000022 ) {
644  ui32TrimValue |= ((( ui32Fcfg1Value &
648  }
649 
650  return(ui32TrimValue);
651 }
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().

543 {
544  uint32_t ui32TrimValue;
545  uint32_t ui32Fcfg1Value;
546 
547  // Use device specific trim values located in factory configuration
548  // area. All defined register bit fields have a corresponding trim
549  // value in the factory configuration area
550  ui32Fcfg1Value = HWREG(FCFG1_BASE + FCFG1_O_AMPCOMP_TH1);
551  ui32TrimValue = (((ui32Fcfg1Value &
555  ui32TrimValue |= (((ui32Fcfg1Value &
559  ui32TrimValue |= (((ui32Fcfg1Value &
563  ui32TrimValue |= (((ui32Fcfg1Value &
567 
568  return(ui32TrimValue);
569 }
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().

508 {
509  uint32_t ui32TrimValue;
510  uint32_t ui32Fcfg1Value;
511 
512  // Use device specific trim value located in factory configuration
513  // area. All defined register bit fields have corresponding trim
514  // value in the factory configuration area
515  ui32Fcfg1Value = HWREG(FCFG1_BASE + FCFG1_O_AMPCOMP_TH2);
516  ui32TrimValue = ((ui32Fcfg1Value &
520  ui32TrimValue |= (((ui32Fcfg1Value &
524  ui32TrimValue |= (((ui32Fcfg1Value &
528  ui32TrimValue |= (((ui32Fcfg1Value &
532 
533  return(ui32TrimValue);
534 }
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().

392 {
393  uint32_t ui32Fcfg1Value ;
394  uint32_t ui32XoscHfRow ;
395  uint32_t ui32XoscHfCol ;
396  uint32_t ui32TrimValue ;
397 
398  // Use device specific trim values located in factory configuration
399  // area for the XOSC_HF_COLUMN_Q12 and XOSC_HF_ROW_Q12 bit fields in
400  // the ANABYPASS_VALUE1 register. Value for the other bit fields
401  // are set to 0.
402 
403  ui32Fcfg1Value = HWREG(FCFG1_BASE + FCFG1_O_CONFIG_OSC_TOP);
404  ui32XoscHfRow = (( ui32Fcfg1Value &
407  ui32XoscHfCol = (( ui32Fcfg1Value &
410 
411  if (( ccfg_ModeConfReg & CCFG_MODE_CONF_XOSC_CAP_MOD ) == 0 ) {
412  // XOSC_CAP_MOD = 0 means: CAP_ARRAY_DELTA is in use -> Apply compensation
413  // XOSC_CAPARRAY_DELTA is located in bit[15:8] of ccfg_ModeConfReg
414  // Note: HW_REV_DEPENDENT_IMPLEMENTATION. Field width is not given by
415  // a define and sign extension must therefore be hard coded.
416  // ( A small test program is created verifying the code lines below:
417  // Ref.: ..\test\small_standalone_test_programs\CapArrayDeltaAdjust_test.c)
418  int32_t i32CustomerDeltaAdjust =
419  (((int32_t)( ccfg_ModeConfReg << ( 32 - CCFG_MODE_CONF_XOSC_CAPARRAY_DELTA_W - CCFG_MODE_CONF_XOSC_CAPARRAY_DELTA_S )))
421 
422  while ( i32CustomerDeltaAdjust < 0 ) {
423  ui32XoscHfCol >>= 1; // COL 1 step down
424  if ( ui32XoscHfCol == 0 ) { // if COL below minimum
425  ui32XoscHfCol = 0xFFFF; // Set COL to maximum
426  ui32XoscHfRow >>= 1; // ROW 1 step down
427  if ( ui32XoscHfRow == 0 ) { // if ROW below minimum
428  ui32XoscHfRow = 1; // Set both ROW and COL
429  ui32XoscHfCol = 1; // to minimum
430  }
431  }
432  i32CustomerDeltaAdjust++;
433  }
434  while ( i32CustomerDeltaAdjust > 0 ) {
435  ui32XoscHfCol = ( ui32XoscHfCol << 1 ) | 1; // COL 1 step up
436  if ( ui32XoscHfCol > 0xFFFF ) { // if COL above maximum
437  ui32XoscHfCol = 1; // Set COL to minimum
438  ui32XoscHfRow = ( ui32XoscHfRow << 1 ) | 1; // ROW 1 step up
439  if ( ui32XoscHfRow > 0xF ) { // if ROW above maximum
440  ui32XoscHfRow = 0xF; // Set both ROW and COL
441  ui32XoscHfCol = 0xFFFF; // to maximum
442  }
443  }
444  i32CustomerDeltaAdjust--;
445  }
446  }
447 
448  ui32TrimValue = (( ui32XoscHfRow << DDI_0_OSC_ANABYPASSVAL1_XOSC_HF_ROW_Q12_S ) |
449  ( ui32XoscHfCol << DDI_0_OSC_ANABYPASSVAL1_XOSC_HF_COLUMN_Q12_S ) );
450 
451  return (ui32TrimValue);
452 }
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().

660 {
661  uint32_t dblrLoopFilterResetVoltageValue = 0; // Reset value
662 
663  if ( ui32Fcfg1Revision >= 0x00000020 ) {
664  dblrLoopFilterResetVoltageValue = ( HWREG( FCFG1_BASE + FCFG1_O_MISC_OTP_DATA_1 ) &
667  }
668 
669  return ( dblrLoopFilterResetVoltageValue );
670 }
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().

767 {
768  uint32_t getTrimForRadcExtCfgValue = 0x403F8000; // Recommended default setting
769  uint32_t fcfg1Data;
770 
771  if ( ui32Fcfg1Revision >= 0x00000020 ) {
772  fcfg1Data = HWREG( FCFG1_BASE + FCFG1_O_MISC_OTP_DATA_1 );
773  getTrimForRadcExtCfgValue =
774  ( ( ( fcfg1Data & FCFG1_MISC_OTP_DATA_1_HPM_IBIAS_WAIT_CNT_M ) >>
777 
778  getTrimForRadcExtCfgValue |=
779  ( ( ( fcfg1Data & FCFG1_MISC_OTP_DATA_1_LPM_IBIAS_WAIT_CNT_M ) >>
782 
783  getTrimForRadcExtCfgValue |=
784  ( ( ( fcfg1Data & FCFG1_MISC_OTP_DATA_1_IDAC_STEP_M ) >>
787  }
788 
789  return ( getTrimForRadcExtCfgValue );
790 }
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().

799 {
800  uint32_t trimForRcOscLfIBiasTrimValue = 0; // Default value
801 
802  if ( ui32Fcfg1Revision >= 0x00000022 ) {
803  trimForRcOscLfIBiasTrimValue = ( HWREG( FCFG1_BASE + FCFG1_O_OSC_CONF ) &
806  }
807 
808  return ( trimForRcOscLfIBiasTrimValue );
809 }
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().

461 {
462  uint32_t ui32TrimValue;
463 
464  // Use device specific trim values located in factory configuration
465  // area
466  ui32TrimValue =
471 
472  ui32TrimValue |=
477 
478  return(ui32TrimValue);
479 }
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().

717 {
718  uint32_t getTrimForXoschfCtlValue = 0; // Recommended default setting
719  uint32_t fcfg1Data;
720 
721  if ( ui32Fcfg1Revision >= 0x00000020 ) {
722  fcfg1Data = HWREG( FCFG1_BASE + FCFG1_O_MISC_OTP_DATA_1 );
723  getTrimForXoschfCtlValue =
724  ( ( ( fcfg1Data & FCFG1_MISC_OTP_DATA_1_PEAK_DET_ITRIM_M ) >>
727 
728  getTrimForXoschfCtlValue |=
729  ( ( ( fcfg1Data & FCFG1_MISC_OTP_DATA_1_HP_BUF_ITRIM_M ) >>
732 
733  getTrimForXoschfCtlValue |=
734  ( ( ( fcfg1Data & FCFG1_MISC_OTP_DATA_1_LP_BUF_ITRIM_M ) >>
737  }
738 
739  return ( getTrimForXoschfCtlValue );
740 }
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().

749 {
750  uint32_t ui32XoscHfFastStartValue ;
751 
752  // Get value from FCFG1
753  ui32XoscHfFastStartValue = ( HWREG( FCFG1_BASE + FCFG1_O_OSC_CONF ) &
756 
757  return ( ui32XoscHfFastStartValue );
758 }
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().

488 {
489  uint32_t ui32TrimValue;
490 
491  // Use device specific trim value located in factory configuration
492  // area
493  ui32TrimValue =
497 
498  return(ui32TrimValue);
499 }
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().

818 {
819  uint32_t trimForXoscLfRegulatorAndCmirrwrRatioValue = 0; // Default value for both fields
820 
821  if ( ui32Fcfg1Revision >= 0x00000022 ) {
822  trimForXoscLfRegulatorAndCmirrwrRatioValue = ( HWREG( FCFG1_BASE + FCFG1_O_OSC_CONF ) &
826  }
827 
828  return ( trimForXoscLfRegulatorAndCmirrwrRatioValue );
829 }
void SetupSetAonRtcSubSecInc ( uint32_t  subSecInc)

Doing the tricky stuff needed to enter new RTCSUBSECINC value.

Parameters
subSecInc
Returns
None

Referenced by SetupAfterColdResetWakeupFromShutDownCfg3().

883 {
884  // Loading a new RTCSUBSECINC value is done in 5 steps:
885  // 1. Write bit[15:0] of new SUBSECINC value to AUX_WUC_O_RTCSUBSECINC0
886  // 2. Write bit[23:16] of new SUBSECINC value to AUX_WUC_O_RTCSUBSECINC1
888  // 4. Wait for AUX_WUC_RTCSUBSECINCCTL_UPD_ACK
891  HWREG( AUX_WUC_BASE + AUX_WUC_O_RTCSUBSECINC1 ) = (( subSecInc >> 16 ) & AUX_WUC_RTCSUBSECINC1_INC23_16_M );
892 
896 }
void SetupSetCacheModeAccordingToCcfgSetting ( void  )

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

Returns
None

Referenced by SetupTrimDevice().

838 {
839  // - Make sure to enable aggressive VIMS clock gating for power optimization
840  // Only for PG2 devices.
841  // - Enable cache prefetch enable as default setting
842  // (Slightly higher power consumption, but higher CPU performance)
843  // - IF ( CCFG_..._DIS_GPRAM == 1 )
844  // then: Enable cache (set cache mode = 1), even if set by ROM boot code
845  // (This is done because it's not set by boot code when running inside
846  // a debugger supporting the Halt In Boot (HIB) functionality).
847  // else: Set MODE_GPRAM if not already set (see inline comments as well)
848  uint32_t vimsCtlMode0 ;
849 
850  while ( HWREGBITW( VIMS_BASE + VIMS_O_STAT, VIMS_STAT_MODE_CHANGING_BITN )) {
851  // Do nothing - wait for an eventual ongoing mode change to complete.
852  // (There should typically be no wait time here, but need to be sure)
853  }
854 
855  // Note that Mode=0 is equal to MODE_GPRAM
856  vimsCtlMode0 = (( HWREG( VIMS_BASE + VIMS_O_CTL ) & ~VIMS_CTL_MODE_M ) | VIMS_CTL_DYN_CG_EN_M | VIMS_CTL_PREF_EN_M );
857 
858 
860  // Enable cache (and hence disable GPRAM)
861  HWREG( VIMS_BASE + VIMS_O_CTL ) = ( vimsCtlMode0 | VIMS_CTL_MODE_CACHE );
862  } else if (( HWREG( VIMS_BASE + VIMS_O_STAT ) & VIMS_STAT_MODE_M ) != VIMS_STAT_MODE_GPRAM ) {
863  // GPRAM is enabled in CCFG but not selected
864  // Note: It is recommended to go via MODE_OFF when switching to MODE_GPRAM
865  HWREG( VIMS_BASE + VIMS_O_CTL ) = ( vimsCtlMode0 | VIMS_CTL_MODE_OFF );
866  while (( HWREG( VIMS_BASE + VIMS_O_STAT ) & VIMS_STAT_MODE_M ) != VIMS_STAT_MODE_OFF ) {
867  // Do nothing - wait for an eventual mode change to complete (This goes fast).
868  }
869  HWREG( VIMS_BASE + VIMS_O_CTL ) = vimsCtlMode0;
870  } else {
871  // Correct mode, but make sure PREF_EN and DYN_CG_EN always are set
872  HWREG( VIMS_BASE + VIMS_O_CTL ) = vimsCtlMode0;
873  }
874 }
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 SetupAfterColdResetWakeupFromShutDownCfg1(), and SysCtrlSetRechargeBeforePowerDown().

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