This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

CC2340R5: Power_shutdown API is failing

Part Number: CC2340R5

Tool/software:

Hi Forum,
I am working on project involving multiple GPIO and their interrupts further the same GPIOs are acting as trigger for waking up from shutdown state. The application involves gauging the button press interval and its combination.
The usual(expected) scenario is like:
Button_press --> wake-up-->process_timings --> take_appropriate_action--> shutdown

Everything works fine for single button press i.e upon doing operation it goes to shutdown mode. But when multiple button press occurs the "Power_shutdown" API is failing and device is remaining in ON.

Upon failing the return value was 0xFFFF.
Please let me why it getting failed?

  • Hi Vaibhav,

    Based on prior experience I can verify that the Power TI Driver can prevent shutdown mode if some shutdown GPIOs are in an active or pending state.  This is to prevent an unexpected I/O state during and recovering from shutdown.  Here is Power_shutdown from simplelink_lowpower_f3_sdk_9_11_00_18\source\ti\drivers\power\PowerCC23X0.c:

    /*
     *  ======== Power_shutdown ========
     */
    int_fast16_t Power_shutdown(uint_fast16_t shutdownState, uint_fast32_t shutdownTime)
    {
        int_fast16_t notifyStatus;
        uintptr_t hwiKey;
        uint8_t i;
        bool ioPending = false;
    
        hwiKey = HwiP_disable();
    
        /* Check if there is a constraint to prohibit shutdown */
        if ((Power_getConstraintMask() & (1U << PowerLPF3_DISALLOW_SHUTDOWN)) != 0U)
        {
            HwiP_restore(hwiKey);
            return Power_ECHANGE_NOT_ALLOWED;
        }
    
        /* Check whether we were transitioning to another power state */
        if (powerState != Power_ACTIVE)
        {
            HwiP_restore(hwiKey);
            return Power_EBUSY;
        }
    
        /* Set new transition state to entering shutdown */
        powerState = Power_ENTERING_SHUTDOWN;
    
        /* Signal all clients registered for pre-shutdown notification */
        notifyStatus = PowerCC23X0_notify(PowerLPF3_ENTERING_SHUTDOWN);
    
        for (i = GPIO_pinLowerBound; i <= GPIO_pinUpperBound; i++)
        {
            /* Read WUCFGSD field once and check both values.
             * Use IOC3 since CC2340R2 does not have IOC0, IOC1, or IOC2.
             */
            uint32_t ioShutdownConfig = HWREG(IOC_ADDR(i)) & IOC_IOC3_WUCFGSD_M;
    
            if (((ioShutdownConfig == IOC_IOC3_WUCFGSD_WAKE_HIGH) || (ioShutdownConfig == IOC_IOC3_WUCFGSD_WAKE_LOW)) &&
                (GPIOGetEventDio(i) != 0U))
            {
                ioPending = true;
            }
        }
    
        /* If no IO event is pending on a shutdown wakeup IO, go to shutdown */
        if (ioPending == false && notifyStatus == Power_SOK)
        {
            HWREG(PMCTL_BASE + PMCTL_O_SHTDWN) = PMCTL_SHTDWN_KEY_VALID;
        }
    
        /* If shutdown succeeded, should never get here */
    
        powerState = Power_ACTIVE;
    
        HwiP_restore(hwiKey);
    
        /* If we get here, failed to shutdown, return error code */
        return Power_EFAIL;
    }

    I would recommend servicing all GPIOs and ensuring that they are inactive before entering shutdown.  You can use a periodic timer to continuously check and try to enter shutdown one the procedure has commenced.

    Regards,
    Ryan

  • Thanks Ryan,

    Your solution worked.

    Regards

    Vaibhav