emlib/src/em_emu.c
void EMU_DCDCOptimizeSlice(uint32_t em0LoadCurrent_mA)
{
  uint32_t sliceCount = 0;
  uint32_t rcoBand = (EMU->DCDCLNFREQCTRL & _EMU_DCDCLNFREQCTRL_RCOBAND_MASK)
                     >> _EMU_DCDCLNFREQCTRL_RCOBAND_SHIFT;

  /* Set recommended slice count */
  if ((EMU->DCDCMISCCTRL & _EMU_DCDCMISCCTRL_LNFORCECCM_MASK) && (rcoBand >= emuDcdcLnRcoBand_5MHz)) {
    if (em0LoadCurrent_mA < 20) {
      sliceCount = 4;
    } else if ((em0LoadCurrent_mA >= 20) && (em0LoadCurrent_mA < 40)) {
      sliceCount = 8;
    } else {
      sliceCount = 16;
    }
  } else if ((!(EMU->DCDCMISCCTRL & _EMU_DCDCMISCCTRL_LNFORCECCM_MASK)) && (rcoBand <= emuDcdcLnRcoBand_4MHz)) {
    if (em0LoadCurrent_mA < 10) {
      sliceCount = 4;
    } else if ((em0LoadCurrent_mA >= 10) && (em0LoadCurrent_mA < 20)) {
      sliceCount = 8;
    } else {
      sliceCount = 16;
    }
  } else if ((EMU->DCDCMISCCTRL & _EMU_DCDCMISCCTRL_LNFORCECCM_MASK) && (rcoBand <= emuDcdcLnRcoBand_4MHz)) {
    if (em0LoadCurrent_mA < 40) {
      sliceCount = 8;
    } else {
      sliceCount = 16;
    }
  } else {
    /* This configuration is not recommended. EMU_DCDCInit() applies a recommended
       configuration. */
    EFM_ASSERT(false);
  }

  /* The selected slices are PSLICESEL + 1 */
  sliceCount--;

  /* Apply slice count to both N and P slice */
  sliceCount = (sliceCount << _EMU_DCDCMISCCTRL_PFETCNT_SHIFT
                | sliceCount << _EMU_DCDCMISCCTRL_NFETCNT_SHIFT);
  EMU->DCDCMISCCTRL = (EMU->DCDCMISCCTRL & ~(_EMU_DCDCMISCCTRL_PFETCNT_MASK
                                             | _EMU_DCDCMISCCTRL_NFETCNT_MASK))
                      | sliceCount;

  /* Update current limiters */
  currentLimitersUpdate();
}
/***************************************************************************/
/**
 * @brief
 *   Optimize DCDC slice count based on the estimated average load current
 *   in EM0
 *
 * @param[in] em0LoadCurrent_mA
 *   Estimated average EM0 load current in mA.
 ******************************************************************************/
@brief
Optimize DCDC slice count based on the estimated average load current
in EM0

@param[in] em0LoadCurrent_mA
Estimated average EM0 load current in mA.
@brief Optimize DCDC slice count based on the estimated average load current in EM0 @param [ in ] em0LoadCurrent_mA Estimated average EM0 load current in mA .
void EMU_DCDCOptimizeSlice(uint32_t em0LoadCurrent_mA)
{
  uint32_t sliceCount = 0;
  uint32_t rcoBand = (EMU->DCDCLNFREQCTRL & _EMU_DCDCLNFREQCTRL_RCOBAND_MASK)
                     >> _EMU_DCDCLNFREQCTRL_RCOBAND_SHIFT;
  if ((EMU->DCDCMISCCTRL & _EMU_DCDCMISCCTRL_LNFORCECCM_MASK) && (rcoBand >= emuDcdcLnRcoBand_5MHz)) {
    if (em0LoadCurrent_mA < 20) {
      sliceCount = 4;
    } else if ((em0LoadCurrent_mA >= 20) && (em0LoadCurrent_mA < 40)) {
      sliceCount = 8;
    } else {
      sliceCount = 16;
    }
  } else if ((!(EMU->DCDCMISCCTRL & _EMU_DCDCMISCCTRL_LNFORCECCM_MASK)) && (rcoBand <= emuDcdcLnRcoBand_4MHz)) {
    if (em0LoadCurrent_mA < 10) {
      sliceCount = 4;
    } else if ((em0LoadCurrent_mA >= 10) && (em0LoadCurrent_mA < 20)) {
      sliceCount = 8;
    } else {
      sliceCount = 16;
    }
  } else if ((EMU->DCDCMISCCTRL & _EMU_DCDCMISCCTRL_LNFORCECCM_MASK) && (rcoBand <= emuDcdcLnRcoBand_4MHz)) {
    if (em0LoadCurrent_mA < 40) {
      sliceCount = 8;
    } else {
      sliceCount = 16;
    }
  } else {
    EFM_ASSERT(false);
  }
  sliceCount--;
  sliceCount = (sliceCount << _EMU_DCDCMISCCTRL_PFETCNT_SHIFT
                | sliceCount << _EMU_DCDCMISCCTRL_NFETCNT_SHIFT);
  EMU->DCDCMISCCTRL = (EMU->DCDCMISCCTRL & ~(_EMU_DCDCMISCCTRL_PFETCNT_MASK
                                             | _EMU_DCDCMISCCTRL_NFETCNT_MASK))
                      | sliceCount;
  currentLimitersUpdate();
}
void EMU_DCDCOptimizeSlice ( uint32_t em0LoadCurrent_mA ) { uint32_t sliceCount = 0 ; uint32_t rcoBand = ( EMU -> DCDCLNFREQCTRL & _EMU_DCDCLNFREQCTRL_RCOBAND_MASK ) >> _EMU_DCDCLNFREQCTRL_RCOBAND_SHIFT ; if ( ( EMU -> DCDCMISCCTRL & _EMU_DCDCMISCCTRL_LNFORCECCM_MASK ) && ( rcoBand >= emuDcdcLnRcoBand_5MHz ) ) { if ( em0LoadCurrent_mA < 20 ) { sliceCount = 4 ; } else if ( ( em0LoadCurrent_mA >= 20 ) && ( em0LoadCurrent_mA < 40 ) ) { sliceCount = 8 ; } else { sliceCount = 16 ; } } else if ( ( ! ( EMU -> DCDCMISCCTRL & _EMU_DCDCMISCCTRL_LNFORCECCM_MASK ) ) && ( rcoBand <= emuDcdcLnRcoBand_4MHz ) ) { if ( em0LoadCurrent_mA < 10 ) { sliceCount = 4 ; } else if ( ( em0LoadCurrent_mA >= 10 ) && ( em0LoadCurrent_mA < 20 ) ) { sliceCount = 8 ; } else { sliceCount = 16 ; } } else if ( ( EMU -> DCDCMISCCTRL & _EMU_DCDCMISCCTRL_LNFORCECCM_MASK ) && ( rcoBand <= emuDcdcLnRcoBand_4MHz ) ) { if ( em0LoadCurrent_mA < 40 ) { sliceCount = 8 ; } else { sliceCount = 16 ; } } else { EFM_ASSERT ( false ) ; } sliceCount -- ; sliceCount = ( sliceCount << _EMU_DCDCMISCCTRL_PFETCNT_SHIFT | sliceCount << _EMU_DCDCMISCCTRL_NFETCNT_SHIFT ) ; EMU -> DCDCMISCCTRL = ( EMU -> DCDCMISCCTRL & ~ ( _EMU_DCDCMISCCTRL_PFETCNT_MASK | _EMU_DCDCMISCCTRL_NFETCNT_MASK ) ) | sliceCount ; currentLimitersUpdate ( ) ; }
@brief
   Optimize DCDC slice count based on the estimated average load current
   in EM0
@brief Optimize DCDC slice count based on the estimated average load current in EM0
/* Set recommended slice count */ /* This configuration is not recommended. EMU_DCDCInit() applies a recommended
       configuration. */ /* The selected slices are PSLICESEL + 1 */ /* Apply slice count to both N and P slice */ /* Update current limiters */