- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
Solved! Go to Solution.
- Labels:
-
PSOC5 LP MCU
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
Pins
Tera Term logs
1. When program started
Start up message is printed and the on board LED is blinking
2. When sw1 is pushed
The program goes into CyPmHibernate() and the LED turned off
3. When sw1 is pushed again
Program reports that it wok up. And the LED starts blinking again.
#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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
Pins
Tera Term logs
1. When program started
Start up message is printed and the on board LED is blinking
2. When sw1 is pushed
The program goes into CyPmHibernate() and the LED turned off
3. When sw1 is pushed again
Program reports that it wok up. And the LED starts blinking again.
#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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
EDITED!!!
Hello Tanaka-san,
Thank you for sharing the project. Works great!!!
I was wondering on how we can use CyPmSleep() API and implement the normal sleep functionality.
Can you please help with this?
Also, from the program shared above, what would need to be changed in order to use the EZI2C (Similar to Lesson 17) instead of the switch?
-- I understand that the Deep Sleep function is not supported by PSOC 5LP (System Reference Guide, Pg. 49, Table.1).
Regards,
Yash
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
I have just posted a sample for Lesson 16.
I'm going to work on Lesson 17, but I don't know when it's going to be available...
moto
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello Tanaka-san,
I downloaded the project attached with the code example and tried to run it.
The device goes to sleep, but there's no wake up text on UART even after waiting for a minute.
The UART log:
Can you think of what can be the issue causing this?
Regards,
Yash
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
It was my bad, seeing the table, I realized that we can not wake up using timer interrupt.
So I deleted my code example thread.
We may be able to use CTW, which I have been trying, but not successful yet.
I will add reply if I will be able to find a method.
But for the time being please survive with the lesson 17 example 😉
moto
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
For the lesson 17, as you found, we don't have "Deep Sleep" and we can not wake up from Hibernate using I2C as the table below suggests.
So I modified the lesson 17 to use "CyPmSleep()"
1. Schematic
2. I2C (EZI2C) Config
Note: I2C1 is needed to be used!
3. Pins
main.c
#include "project.h"
#include "stdio.h"
#define LED_ON 1u
#define LED_OFF 0u
void blink_led(int num)
{
int i ;
for (i = 0 ; i < num ; i++ ) {
LED_Write(LED_ON) ;
CyDelay(100) ;
LED_Write(LED_OFF) ;
CyDelay(100) ;
}
}
int main(void)
{
uint8_t i2cbuf[1] ;
CyGlobalIntEnable; /* Enable global interrupts. */
EZI2C_Start() ;
EZI2C_SetBuffer1(1, 1, i2cbuf) ;
for(;;)
{
blink_led(4) ;
EZI2C_Sleep() ;
CyPmSaveClocks();
// CyPmHibernate();
CyPmSleep(PM_SLEEP_TIME_NONE, PM_SLEEP_SRC_I2C) ;
CyPmRestoreClocks(); // <= Stack in this process
EZI2C_Wakeup() ;
CyDelay( 5000 ) ;
}
}
Can we call it a week?
moto
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Tanaka-san,
Thanks for all your help!!!🙌
You really are a life-saver and very knowledgeable.
I just had a small doubt as to why we can't use I2C0 and only need to use I2C1 for Lesson17?
Regards,
Yash
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
In the TRM, there is the following table.
According to the table, P12[0:1] are for I2C1 (as their dedicated I/Os).
Although I2C0 may be able to use these pins, the signals need to go through
other internal switch(es) and they may not be working when the device is in low power mode.
moto