- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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?
- Labels:
-
PSoC 5LP
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
You did not remove your isr_ButtonPress component.
Ah, I made a mistake, the do-while loop was for the alternate case.
Bob
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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