1 2 Previous Next 22 Replies Latest reply on Jan 29, 2012 11:34 PM by udayan.umapathi

    Sleep mode not working as expected

    user_62720120

      Hi,

         

      I am trying to use sleep mode, but I'm experiencing two problems:

         

      1. Only the first sleep seems to work. Subsequent sleep commands seem to pass instantly.

         

      2. Even that first working sleep seems to be the wrong length of time.

         

       

         

      Here is my code:

         

       

         

      void main()
      {
          UART_Debug_Start();
         
          UART_Debug_PutString("\r\nHello\r\n");
          CyDelay(2000);

          while(1)
          {
              UART_Debug_PutString("going to sleep ...\r\n");
              while(UART_Debug_GetTxBufferSize())                  // Wait for the UART to finish
              {
              }
              CyDelay(5);                                          // Still needs more time
             
              UART_Debug_Sleep();
             
              CyPmSaveClocks();
              CyPmSleep(PM_SLEEP_TIME_CTW_4096MS, PM_SLEEP_SRC_NONE);
              CyPmReadStatus();
              CyPmRestoreClocks();

              UART_Debug_Wakeup();

              CyDelay(5);                                          // Needed otherwise UART doesn't work.
              UART_Debug_PutString("...woken up\r\n");
              CyDelay(4096);
          }
      }

         

       

         

      What have I forgotten?

         

      Many thanks - Hugo

        1 2 Previous Next