This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

TM4C1294NCZAD: Wake up from deep sleep

Part Number: TM4C1294NCZAD

Hello

I'm trying to set my MCU (Tiva TM4C1294NCZAD) in deep sleep and then wake up from an external button. I started from sleep_modes example, and I wrote the "go to sleep" function as:

void GoToSleep()
{
  /* Set the clocking for Deep-Sleep.
   * Power down the PIOSC & MOSC to save power and run from the
   * internal 30kHz osc.
   */
  SysCtlDeepSleepClockConfigSet(1, (SYSCTL_DSLP_OSC_INT30 |
    SYSCTL_DSLP_PIOSC_PD | SYSCTL_DSLP_MOSC_PD));

  /* Enable the Button Port in Deep-Sleep Mode and auto clock gating */
  SysCtlPeripheralClockGating(true);

  SysCtlPeripheralDeepSleepEnable(SYSCTL_PERIPH_GPIOK);

  /* Set LDO to 1.10V in Deep-Sleep. */
  SysCtlLDODeepSleepSet(SYSCTL_LDO_1_10V);

  /* Set Flash & SRAM to Low Power in Deep-Sleep Mode. */
  SysCtlDeepSleepPowerSet(SYSCTL_FLASH_LOW_POWER | SYSCTL_SRAM_LOW_POWER);

  /* FreeRTOS function to suspende scheduler */
  vTaskSuspendAll();
  
  SysCtlDeepSleep();
}

I enable only GPIO K port in deep-sleep because my button is connected to pin K5. its associated isr is the following:

static int test = 0;
void BUTTON_Handler(uint32_t index)
{
  if(!test)
  {
    GoToSleep();
    test = 1;
  }
  else
    HAL_System_Reset();
}

When I press the button the first time, MCU correctly goes in deep-sleep state. But then, whenever I press the button, MCU never wakes up! I never the see system reset, neither consumptions increase, so I assume it doesn't return to run mode. Am i missing anything in this procedure?

Thank you

  • I am missing too much of the initialization. Are you able to export your project to a .zip file and attach it? If you prefer not to post it on the forum, please request me as a friend and you can then email me the .zip file.
  • Sorry my fault. The problem seems that I cannot call the SysCtlDeepSleep() function from an interrupt context!
    I moved it inside my main task, after a 10 seconds delay, and now it works. Am I right?
    Thank you anyway, I let you know if I've further problems.