/***
 *** The example has no copyright and can be used by anyone.
 *** The following example is based on Device File Package
 *** required to compile the macro definitions used.
 *** The Device File Package is available by downloading Atmel Studio 7.
 ***/
void Optimize_LowPower(void)
{

 /*** nLDO/Buck Regulator mode 
  *** Select Buck = 1
  ***/
 SUPC->VREG.bit.SEL = 1;
 while(SUPC->STATUS.bit.VREGRDY==0);

 /*** check if the MAINREG low power mode is established ***/
 while(SUPC->STATUS.bit.ULPVREFRDY==0);

 /*** Allow to use low power ref for vreg ***/
 SUPC->VREG.bit.VREFSEL = 1;

 /*** Set Low power Mode Efficiency 
  *** for the Low Power Voltage Regulator (LPVREG)
  *** !!!! Apply this when power voltage is above 2.5 V !!!!
  ***/
 SUPC->VREG.bit.LPEFF = 0x1;

}