GPIO Wakeup from Hibernate

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
MikeAustin
Level 4
Level 4
25 replies posted 25 sign-ins 10 replies posted

OK, so I have a project that involves:

  1. PSOC4100 BLE unit going into Hibernate mode to save power
  2. One of two different GPIO pins (STRIKE and VEXT) are to wake the MCU out of Hibernate mode
  3. I then run different code snippets depending upon which pin caused the interrupt

My code at this point looks like this.  I've not put any meat on the bones just yet, as I'm still trying to get the basic structure clear in my head.  What I'm trying to understand is, when the MCU resets after being triggered out of Hibernate by one of my GPIO, will either of the two ISR's I've got actually get called (the appropriate pins are linked to the appropriate interrupt component)?  Or is that not how the "wakeup using GPIO interrupt" process actually works?  Do I have to rely on the call to CySysPmGetResetReason() to establish that I've come out of Hibernate, and then check the pins registers somehow?

Just looking for some guidance to get me sorted

Cheers,

Mike

int main(void)

{

    InitializeSystem();

     

    for(;;)

    {

        CySysPmFreezeIo();  // Freeze IO to prevent unwanted changes

        CySysPmHibernate(); // Put the chip into Hibernate mode.      

    }

}

CY_ISR(StrikeIsrHandler)

{

    /* This ISR services a strike count interrupt and updates the strike counter. */

    /*Increment strike counter and write time stamp to flash */

    isr_STRIKE_ClearPending();

    STRIKE_ClearInterrupt();

}

CY_ISR(VExtIsrHandler)

{

    /*This ISR services an interrupt generated when the external power supply is connected */

    /* Activate analog switch, check battery voltage and broadcast BLE */

    isr_VEXT_ClearPending();

    VEXT_ClearInterrupt();

}

void InitializeSystem(void)

{

    /* Set up GPIO interrupts and enable them */

    isr_STRIKE_StartEx(StrikeIsrHandler);

    isr_VEXT_StartEx(VExtIsrHandler);

   

    /* Enable global interrupts */

    CyGlobalIntEnable;

   

    isr_STRIKE_ClearPending();

    STRIKE_ClearInterrupt();

   

    isr_VEXT_ClearPending();

    VEXT_ClearInterrupt();

   

    /* Check the source of reset

     * 1. Power on - reset strike count

     * 2. Strike detected - update strike count

     * 3. External power connected - adverstise data

     */

    if (CySysPmGetResetReason() != CY_PM_RESET_REASON_WAKEUP_HIB )

    {

        /* Initialise strike_counter only when not being woken up from Hibernate mode */

        strike_counter = 0;

    }

    else

    {

        CheckInterruptCause();

    }

    CySysPmUnfreezeIo();

}

0 Likes
1 Solution
lock attach
Attachments are accessible only for community members.
Rakshith
Moderator
Moderator
Moderator
250 likes received 1000 replies posted 750 replies posted

Hi MiAu_3808196​,

I have modified your code a bit to detect which pin caused the system to wake up from hibernate mode. I used a variable to achieve this. The variable is set to 1 in StrikeIsrHandler and 0 in VExtIsrHandler.  I am checking for this variable in the main code and depending on the value I am blinking the LED once or twice.

I have attached the project for your reference. I have used CY8CKIT-043 (PSoC 4200M). Please change the device and the pins accordingly.

You can also refer to Hibernate_PSoC4_Example Code Example. For more information related to Hibernate Mode please refer PSoC 4 BLE Architecture TRM.

Thanks and Regards,

Rakshith M B

Thanks and Regards,
Rakshith M B

View solution in original post

0 Likes
2 Replies
lock attach
Attachments are accessible only for community members.
Rakshith
Moderator
Moderator
Moderator
250 likes received 1000 replies posted 750 replies posted

Hi MiAu_3808196​,

I have modified your code a bit to detect which pin caused the system to wake up from hibernate mode. I used a variable to achieve this. The variable is set to 1 in StrikeIsrHandler and 0 in VExtIsrHandler.  I am checking for this variable in the main code and depending on the value I am blinking the LED once or twice.

I have attached the project for your reference. I have used CY8CKIT-043 (PSoC 4200M). Please change the device and the pins accordingly.

You can also refer to Hibernate_PSoC4_Example Code Example. For more information related to Hibernate Mode please refer PSoC 4 BLE Architecture TRM.

Thanks and Regards,

Rakshith M B

Thanks and Regards,
Rakshith M B
0 Likes

Cheers, thanks.  So, it looks like those ISR's do get called once the MCU comes out of Hibernate, so I can either run some code within them, or use a flag as you have done

0 Likes