Announcements
IMPORTANT: Cypress Developer Community is transitioning on October 20th. To learn more and be prepared for this change, check out our latest announcement.
cancel
Showing results for 
Search instead for 
Did you mean: 

PSoC 5, 3 & 1 MCU

Yash_r
New Contributor II

Hello,

In PSoC 101: Lesson 16,  the CySysPmSleep() API doesn't take any arguments whereas when I am trying with PSOC Creator 4.4, there is no CySysPmSleep() API, but instead a CyPmSleep() API which requires two arguments (Wakeup Time, Wakeup source). 
I have gone through the inbuilt Sleep_Timer_Wakeup example which makes use of a special Sleep_Timer component (I think)... and also tried using the CyPmSaveClocks() and CyPmRestoreClocks() API's before and after calling the CyPmSleep() API --> The device goes to sleep, but doesn't wakeup.

Can anyone help understand how to bring the same functionality of Lesson 16, using a user-defined timer to the sleep project?

Similarly in Lesson 17, the deep sleep mode is achieved using the CySysPmDeepSleep() API (which is not available), and so i tried using CyPmHibernate() (similar to the PowerManagement_Hibernate example firmware), but when trying to write to the i2cbuf from the Bridge Control Panel application, the Slave is NACKing the commands --> Failure.


Please help on how to implement these examples with CY8CKIT-059 and PSoC Creator 4.4.

Regards,
Yash

0 Likes
1 Solution
MotooTanaka
Esteemed Contributor

Hi,

Although it's not exactly the 101 is showing, I found a sample which I wrote last year.

I hope this can be some hint for you.

Schematic

001-schematic.JPG

Pins

002-Pins.JPG

Tera Term logs

1. When program started

Start up message is printed and the on board LED is blinking

003-started.JPG

2. When sw1 is pushed

The program goes into CyPmHibernate() and the LED turned off

004-sw_pushed.JPG

3. When sw1 is pushed again

Program reports that it wok up. And the LED starts blinking again.

005-sw_pushed_again.JPG

#include "project.h"
#include "stdio.h"

#define LED_ON 1u
#define LED_OFF 0u

#define STR_LEN 64
char str[STR_LEN+1] ;
void print(char *str) ;
void cls(void) ;
void splash(char *prog_name) ;
void init_hardware(void) ;

volatile int sw_flag = 0 ;

CY_ISR(sw1_isr)
{
    SW1_ClearInterrupt() ;
    sw_flag = 1 ;
}

int main(void)
{
    init_hardware() ;
    
    splash("5LP Repeated LowPower Test") ;

    LED_Write(LED_ON) ;
    
    for(;;)
    {
        if (sw_flag) {
            print("Entering Low Power Mode ... ") ;
            CyDelay(10) ;
            CyDelayUs(20);
            CyPmSaveClocks();
            LED_Write(LED_OFF) ;
            CyPmHibernate();
            CyPmRestoreClocks(); // <= Stack in this process
            CyDelayUs(20);
            print("Woke Up!\n\r") ;
            sw_flag = 0 ;
        }
        LED_Write(!LED_Read()) ;
        CyDelay(500) ;
    }
}

void init_hardware(void)
{
    CyGlobalIntEnable; /* Enable global interrupts. */
    
    LED_Write(LED_OFF) ;
    
    UART_Start() ;
    
    SW1_ClearInterrupt() ;
    isr_1_ClearPending() ;
    isr_1_StartEx(sw1_isr) ;
}

void print(char *str)
{
    UART_PutString(str) ;
}

void cls(void)
{
    print("\033c") ; /* reset */
    CyDelay(20) ;
    print("\033[2J") ; /* clear screen */
    CyDelay(20) ;
}

void splash(char *prog_name) 
{
    cls() ;
    if (prog_name && *prog_name) {
        print(prog_name) ;
    } 
    print(" (") ;
    print(__DATE__) ;
    print(" ") ;
    print(__TIME__) ;
    print(")\n") ;
}

 

moto

View solution in original post

0 Likes
9 Replies