I had the same problem using deep sleep mode (LPC_PMC->PD0_SLEEP0_MODE = PMC_PWR_DEEP_SLEEP_MODE):
Setting LPC_PMC->PD0_SLEEP0_HW_ENA = 0x2 seems to put the whole chip in a weird state. The GPIO state seems to be completely lost. Current consumption is unknown, as the peripherals on my board use a lot of power with the GPIOs in undefined state. As far as I have seen this happens in two cases:
Solution/workaround:
The order in which the LPC_PMC registers are set seem to be important. It looks like the PD0_SLEEP0_HW_ENA register must be set after PD0_SLEEP0_MODE, contrary to the order as described in the user manual 12.2.3. See below for a fixed version of PCM_Set_PwrState(). Note the addition at line 15:
typedef enum {
ENA_EVENT0 = (1 << 0),
ENA_EVENT1 = (1 << 1)
} ENA_EVENT;
void PMC_Set_PwrState(CHIP_PMC_PWR_STATE_T pwr_state, ENA_EVENT ena_event)
{
uint32_t prev_scr = SCB->SCR;
// Set deep sleep mode bit in core-specific System Control Register
SCB->SCR|= 0x4;
/* Set power state in PMC */
LPC_PMC->PD0_SLEEP0_MODE = (uint32_t) pwr_state;
LPC_PMC->PD0_SLEEP0_HW_ENA = (uint32_t) ena_event;
__WFI();
// restore deep sleep bit
SCB->SCR = prev_scr & 0x1F;
}
So far this code works for me. To put the LPC43xx in deep sleep mode from the M0 core, call the new PMC_Set_PwrState function:
// Put the LPC43xx in deep sleep from the M0 core
PMC_Set_PwrState(PMC_PWR_DEEP_SLEEP_MODE, ENA_EVENT1);