RTC Sleep Problems

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
GeMo_285911
Level 4
Level 4
First like received

Hello,

   

  I am sure I am missing something here.

   

  Could someone explain to me why the following code does not work? It works when I replace the sleep part with an one second delay.

   

#include <project.h>

   


int main()
{
    
    CyGlobalIntEnable; /* Enable global interrupts. */
      
    //enable the 1 second interval for RTC interrupt
    RTC_WriteIntervalMask(RTC_INTERVAL_SEC_MASK);
    
    //start the RTC
    RTC_Start();
    
    RTC_EnableInt();
    
    /* Place your initialization/startup code here (e.g. MyInst_Start()) */
    
    LED1_Write(0);
    
    for(;;)
    {
        LED1_Write(~LED1_Read());
        
        
        CyPmSaveClocks();
        
        RTC_DisableInt();
        
        CyPmSleep(PM_SLEEP_TIME_NONE,PM_SLEEP_SRC_ONE_PPS);
        
        CyPmRestoreClocks();
        
        RTC_EnableInt();
    }
}

   

Thank you!

   

George

0 Likes
1 Solution
lock attach
Attachments are accessible only for community members.
GeMo_285911
Level 4
Level 4
First like received

Hello, 

   

  I attached the project. Maybe it's something electrical, since I have a separate source for the LED, controlled through another PSoC output. However, it does not work. Anyway, it was solved by the external RTC, which, I thing, is a better solution.

   

  Thank you for your time!

   

George

View solution in original post

0 Likes
5 Replies
ETRO_SSN583
Level 9
Level 9
250 likes received 100 sign-ins 5 likes given

Post your project so forum can see all settings -

   

 

   

“File”                                                             Creator

   

“Create Workspace Bundle”

   

 

   

 

   

Regards, Dana.

0 Likes
GeMo_285911
Level 4
Level 4
First like received

Hi Dana,

   

  I am sorry, but I don't have the project any more, since I changed to an external RTC with a 1Hz IRQ signal. However, I had the 32kHz clock activated and a RTC component instantiated. The project compiled without giving any error.

   

Thanks,

   

George

0 Likes
Anonymous
Not applicable

Hi, Only thing I can see is there should be some delay after power up before you put device into sleep. CyDelay(100) before main loop might help. 

0 Likes
lock attach
Attachments are accessible only for community members.
GeMo_285911
Level 4
Level 4
First like received

Hello, 

   

  I attached the project. Maybe it's something electrical, since I have a separate source for the LED, controlled through another PSoC output. However, it does not work. Anyway, it was solved by the external RTC, which, I thing, is a better solution.

   

  Thank you for your time!

   

George

0 Likes
GeMo_285911
Level 4
Level 4
First like received

THE RTC COMPONENT WAKES UP THE PSoC FROM SLEEP ONLY WITH EXTERNAL 32kHz CRYSTAL.

   

Sorry for the trouble!