Hi All,
I have a system that samples data from some sensors and then goes into deep sleep mode. The way that the system gets waked up from deep sleep is through a GPIO interrupt from an outside source. There are multiple GPIO interrupt sources for my system, therefore my system can be waked up by different sources.
Later I realized that my system will occasionally not wake up from deep sleep mode. After looking into the TM4C123 errata, I realized that my system setup hits the SYSCTL#01 problem, With a Specific Clock Configuration, Device may not Wake From Deep Sleep Mode.
As a result I chose the workaround to disable the PLL before going into deep sleep mode and to enable the PLL whenever a GPIO interrupt is triggered (enable PLL within individual ISR)
Here is a problem; before entering deep sleep, I will disable PLL, however, if at this very moment before the deep sleep API is called, a GPIO interrupt comes in and enables the PLL, my system is then under the condition of the errata before going into deep sleep, which will render my system the chance of unable to be waked up from deep sleep.
// Pseudo Code
// typical GPIO ISR
void GPIO_ISR(){
Enable_PLL();
Do ISR stuffs ...
}
...
// clock setting for run state (wake state)
SysCtlClockSet(SYSCTL_SYSDIV_4 | SYSCTL_XTAL_16MHZ | SYSCTL_USE_PLL | SYSCTL_OSC_MAIN);
....
// .... procedures before entering deep sleep
SysTickDisable();
SystemDeepSleepClockSet(SYSCTL_DSLP_DIV_4 | SYSCTL_DSLP_OSC_INT30 | SYSCTL_DSLP_PIOSC_PD);
SysCtlClockSet(SYSCTL_SYSDIV_4 | SYSCTL_XTAL_16MHZ | SYSCTL_USE_OSC | SYSCTL_OSC_MAIN); // Disable PLL
SysCtlDeepSleepPowerSet(SYSCTL_TEMP_LOW_POWER | SYSCTL_FLASH_LOW_POWER | SYSCTL_SRAM_LOW_POWER);
SysCtlLDODeepSleepSet(SYSCTL_LDO_0_90V);
>>> Oh no GPIO interrupt comes in here and enables PLL <<<
SysCtlDeepSleep();
One thought I had for this problem was to enclose this section of the code within a critical section which should prevent interrupts from altering my PLL setting during this period. However, there still exists a small gap for interrupts between leaving the critical section and entering deep sleep. Therefore, this workaround of mine is not good enough.
Can anyone help me on this one? Is there any way that I can disable PLL and enter deep sleep smoothly without any interference? I would prefer not altering my system settings and not use PIOSC but any workarounds is deeply appreciated.
Thanks in advance!
Jacky