2 Replies Latest reply on Mar 24, 2020 5:40 PM by MiAu_3808196

    GPIO Wakeup from Hibernate

    MiAu_3808196

      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();

      }