5 Replies Latest reply on Jan 10, 2015 12:59 PM by vyas.savanur

    PSoC 5 Sleep and Wakeup with PICU

    vyas.savanur

      Hello All,

         

      I was interested in understanding PSoC low power modes, so I searched the Cypress website and found AN77900 http://www.cypress.com/?rID=64554

         

      I downloaded the example projects and was able to get them to work on the CY8CKIT-050. However, I then wanted to create my own project. The first thing I tried was puting the PSoC to sleep using a button, and then waking it up using that same button. This example is in the AN77900 project.

         

      In my program, the PSoC seems to go to sleep, but it does not wakeup.

         

      Here is the function that puts the PSoC to sleep and wakes it up:

         

      void CustomSleep()
      {
          /* Display mode. */
          LCD_Position(1,0);
          LCD_PrintString("Sleep-PICU      ");
         
          /* Start the button interrupt. */
          isr_ButtonPress_Start();
         
          /* Prepare for Sleep and enter it. */
          IDAC8_1_Sleep();
          CyPmSaveClocks();
          CyPmSleep(PM_SLEEP_TIME_NONE, PM_SLEEP_SRC_PICU);
         
          /* The PSoC wakes up here. Clear wakeup interrupts. */
          CyPmRestoreClocks();
          IDAC8_1_Wakeup();
         
          /* Stop the button interrupt. */
          isr_ButtonPress_Stop();
          Button_ClearInterrupt();
         
          LCD_Position(1,0);
          LCD_PrintString("Wakey-PICU");
         
          ButtonDebounce();
      }

         

      I think I set up the button and ISR the same as the example, but I seem to have missed something. Any ideas?

        • 1. Re: PSoC 5 Sleep and Wakeup with PICU
          user_1377889

          The isr_ButtonPress is not needed and will probably not work during sleep mode. The interrupt will be generated by the PICU that is directly connected to the ports.

             

          In the example file is a do-while loop that stays active as long as there are any button interrupts pending. This you do not do in your code.

             

           

             

          Bob

          • 2. Re: PSoC 5 Sleep and Wakeup with PICU
            vyas.savanur

            Thanks for the reply Bob. I don't think I see the do-while loop you are referring to.

               

            Here is the segment of code in the example that I tried to emulate. It is inside a case statment in the function GoToLowPower:

               

                    case SLEEPPICU : /* 0x21 - Sleep - PICU */
                    {
                        /* Display mode. */
                        LCD_Position(1,0);
                        LCD_PrintString("Sleep-PICU      ");
                        /* Start the button interrupt. */
                        isr_ButtonPress_Start();
                        /* Prepare for Sleep and enter it. */
                        SleepComponents();
                        CyPmSaveClocks();
                        CyPmSleep(PM_SLEEP_TIME_NONE, PM_SLEEP_SRC_PICU);
                        /* The PSoC wakes up here. Clear wakeup interrupts. */
                        CyPmRestoreClocks();
                        WakeComponents();
                        /* Stop the button interrupt. */
                        isr_ButtonPress_Stop();
                        Button_ClearInterrupt();
                        break;
                    }

               

            This part uses an isr and there is no loop to check for pin interrupts. Which section were you referring to?

            • 3. Re: PSoC 5 Sleep and Wakeup with PICU
              user_1377889

              You did not remove your isr_ButtonPress component.

                 

              Ah, I made a mistake, the do-while loop was for the alternate case.

                 

               

                 

              Bob

              • 4. Re: PSoC 5 Sleep and Wakeup with PICU
                vyas.savanur

                Ah yes, I see the do-while in the alternate case.

                   

                As for the isr_ButtonPress, it is used in the example code and that's why I put it in mine. If I comment out the lines for starting and stopping the isr_ButtonPress in the example code, the PSoC does not wake up.

                • 5. Re: PSoC 5 Sleep and Wakeup with PICU
                  vyas.savanur

                  Well I found the problem. The example had modified the default isr for the isr_ButtonPress. The isr clears the interrupt on Button. When I added this one line into my project, it started working.

                     

                  Now to understand why this makes a difference