Flexi mode in ADUCM3029

Hello,

I'm trying to minimize the power consumption between the interrupts of a system so I opted to use flexi mode. so I've written two functions using the DFP APIs.

Could you confirm or optimize this methodologies

Regards

#include <adi_pwr.h>

void Host_EnterFlexi(void)
{
    bFlexiExitFlag = 0;
   /* automatically exit flexi mode */
   adi_pwr_EnterLowPowerMode(ADI_PWR_MODE_FLEXI, NULL, 0);

}

void Host_ExitFlexi(void)
{
    bFlexiExitFlag = 1;
    adi_pwr_ExitLowPowerMode(&bFlexiExitFlag);
}

  • Hi Messaaoud,

    When using automatic "sleep-on-exit" all wakeup interrupts are dispatched and then automatically put the processor back to sleep on exit. So if you want to exit from low power mode  just put a NULL parameter on  adi_pwr_ExitLowPowerMode() no need to put a flag check.

    Regards,

    Jeric

  • Hello Messaoud,

    Following this link can provide a way to access documentation regarding the use of the device drivers APIs:

    https://ez.analog.com/analog-microcontrollers/ultra-low-power-microcontrollers/w/documents/2468/faq-where-can-i-find-documentation-related-to-aducm302x-or-aducm4050-software-drivers-dfp-bsp

    Using ADuCM302x_DFP version 3.2.0 I came across documentation with the version 3.1.2 so I guess it should still be relevant.

    Getting on topic: first you should make sure the flag is volatile so that the compiler does not optimize it away.

    If you want the "sleep-on-exit" function, where the system only addresses the ISRs then goes automatically back to sleep, you should use

    adi_pwr_EnterLowPowerMode(ADI_PWR_MODE_FLEXI, NULL, 0);

    giving the NULL pointer to the function.

    If you want certain ISRs to exit low power mode for the whole program you should pass the pointer of the flag to the function:

    adi_pwr_EnterLowPowerMode(ADI_PWR_MODE_FLEXI, &bFlexiExitFlag, 0);

    And the ISR that needs to exit the low power mode should contain the call:

    adi_pwr_ExitLowPowerMode(&bFlexiExitFlag);

    Speaking about this code in particular, I think it should work better the following way:

    #include <adi_pwr.h>
    
    volatile uint32_t bFlexiExitFlag;
    
    void Host_EnterFlexi(void)
    {
        bFlexiExitFlag = 0;
       /* exit flexi mode when the flag is set */
       adi_pwr_EnterLowPowerMode(ADI_PWR_MODE_FLEXI, &bFlexiExitFlag, 0);
    
    }
    
    void Host_ExitFlexi(void)
    {
        adi_pwr_ExitLowPowerMode(&bFlexiExitFlag);
    }

    No need to manually set bFlexiExitFlag in Host_ExitFlexi() because adi_pwr_ExitLowPowerMode() does just that.

    Regards,

    Andrei