Wake Up PSoC 6 MCU Device from Deep Sleep Through EZI2C Slave Address Match – KBA227480

Author: ShanmathiN_06           Version: **

 

The SCB_EZI2C_PDL Component can wake up the device from Deep Sleep mode on a Slave address match. To enable this functionality, select the Enable Wakeup from Deep Sleep Mode parameter. Figure 1 shows the PSoC Creator 4.2 configuration settings Figure 2 shows the ModusToolbox configurator settings.

   

Figure 1. PSoC Creator 4.2 Configuration Settings

    

Figure 2. ModusToolbox Device Configurator settings

 

NOTE: Only one of the available SCBs is Deep Sleep capable. You can refer to the Pinouts section: Multiple alternate functions table of PSoC 6 datasheet, where the SCB with Deep Sleep functionality is listed under the DS (Deep Sleep) column.

Perform these steps to register the Deep Sleep callback function using the cy_syspm driver before entering Deep Sleep.

1. Define the cy_stc_syspm_callback_params_t structure reference with the following data fields.

  • void* cy_stc_syspm_callback_params_t::baseBase address of a HW instance. Matches the driver name in the API for the base address.

 

  • void* cy_stc_syspm_callback_params_t::context -> Context for the handler function if your callback routine needs access to the context. Else, this item is defined as NULL.

2. Define the cy_stc_syspm_callback_t structure reference with the following data fields.

  • Cy_SysPmCallback cy_stc_syspm_callback_t::callback -> The callback handler function (Cy_SCB_EZI2C_DeepSleepCallback)

 

  • cy_en_syspm_callback_type_t cy_stc_syspm_callback_t::type -> The Deep Sleep enum callback type (CY_SYSPM_DEEPSLEEP)

 

  • uint32_t cy_stc_syspm_callback_t::skipMode -> The mask of modes to be skipped during callback execution.

 

  • cy_stc_syspm_callback_params_t* cy_stc_syspm_callback_t::callbackParamsThe address of cy_stc_syspm_callback_params_t; the callback is executed with these parameters.

 

  • struct cy_stc_syspm_callback* cy_stc_syspm_callback_t::prevItm -> The previous list item. This element is defined as NULL.

 

  • struct cy_stc_syspm_callback* cy_stc_syspm_callback_t::nextItm -> The next list item. This element is defined as NULL.

 

3. Register the callback function using Cy_SysPm_RegisterCallback (cy_stc_syspm_callback_t * handler).

 

4. Use Cy_SysPm_CpuEnterDeepSleep (CY_SYSPM_WAIT_FOR_INTERRUPT) to enter Deep Sleep. The PSoC 6 MCU device wakes up when an EZI2C address match occurs.

 

See the PDL documentation for more information[BV1] on the structures and APIs.

 

 

Code snippet:

cy_stc_syspm_callback_params_t Cy_SCB_EZI2C_DeepSleepCallback_param =

   {

        sEzI2C_HW,

        NULL

   };

 

cy_stc_syspm_callback_t Cy_SCB_EZI2C_DeepSleepCallback_elements =

   {

&Cy_SCB_EZI2C_DeepSleepCallback,

       CY_SYSPM_DEEPSLEEP,

       0U,

&Cy_SCB_EZI2C_DeepSleepCallback_param,

       NULL,

       NULL

   };

 

 

int main(void)

{

   if (true != Cy_SysPm_RegisterCallback(&Cy_SCB_EZI2C_DeepSleepCallback_elements))

       {

        /* Insert error handling */

       }

 

   if (CY_SYSPM_SUCCESS != Cy_SysPm_CpuEnterDeepSleep(CY_SYSPM_WAIT_FOR_INTERRUPT))

       {        

        /* Insert error handling */

       }

}