I try to use the deep power down.
i use this code on xxx.h:
#define DEEP_POWER_DOWN 3
typedef struct PWRD_API {
void (*set_pll)(uint32_t cmd[], uint32_t resp[]); /*!< Set PLL function */
void (*set_power)(uint32_t cmd[], uint32_t resp[]); /*!< Set power function */
/*!< Sets the chip in low power modes */
void (*power_mode_configure)(unsigned int mode, unsigned int peripheral);
void (*reserved1)();
void (*reserved2)();
} PWRD_API_T;
typedef struct _ROM {
const PWRD_API_T * pPWRD;
} ROM;
#define ROM_DRIVER_BASE (0x03000200UL)
#define LPC_PWRD_API ((PWRD_API_T *) ((*(ROM * *) (ROM_DRIVER_BASE))->pPWRD))
and this code on file.c: to put on deep power down
if (analogValueLen > 0xC00)
{
//deep power down
LPC_PWRD_API->power_mode_configure(DEEP_POWER_DOWN,0);
__WFI();
}
main.c file:
int main (void)
{
//GPIO init
LPC_SYSCON->SYSAHBCLKCTRL0 |= (1UL << 13); /* enable clock for IOCON0 */
LPC_SYSCON->SYSAHBCLKCTRL0 |= (1UL << 14); /* enable clock for GPIO0 */
LPC_SYSCON->SYSAHBCLKCTRL0 |= (1UL << 15); /* enable clock for GPIO1 */
LPC_SYSCON->SYSAHBCLKCTRL0 |= (1UL << 16); /* enable clock for GPIO2 */
LPC_GPIO_PORT->DIR[0] = 0; //input
...
if (LPC_PMU->PCON & 0x00800) //bit 11
{
LPC_PMU->PCON |= 0x00800; //reset le flag!!!!
PDownDetected = 1;
}
else
PDownDetected = 0;
...
}
My question is : i cant wake up the deep power down!!!
The wake up pin (pin #28) has a pullup resistor and if i send a ground pulse or a ground level, it is supposed to wake up the lpc1517 by the POR and the chip re-boots!!!! But nothing happens!!! Am i missing something!!!!
thx in advance for your help!!!!
Solved! Go to Solution.
Thx Victor for your helps :smileyhappy:
I found my problem (pointer location!!!) and i want to post it!!
In my file calcul.h, i have this code:
#define SLEEP 0
#define DEEP_SLEEP 1
#define POWER_DOWN 2
#define DEEP_POWER_DOWN 3
typedef struct PWRD_API {
void (*set_pll)(uint32_t cmd[], uint32_t resp[]); /*!< Set PLL function */
void (*set_power)(uint32_t cmd[], uint32_t resp[]); /*!< Set power function */
void (*power_mode_configure)(unsigned int mode, unsigned int peripheral);
void (*reserved1)();
void (*reserved2)();
} PWRD_API_T;
typedef struct _ROM {
const unsigned p_dev0;
const unsigned p_dev1;
const unsigned p_dev2;
const PWRD_API_T * pPWRD; /* ROM Power Management API */
const unsigned p_dev4;
const unsigned p_dev5;
const unsigned p_dev6;
const unsigned p_dev7;
} ROM_API;
and on my main.c
#include "calcul.h"
...
static ROM_API ** romAPI = (ROM_API **) 0x03000200; /* pointer to power API calls */
...
int main(void)
{
...
if (LPC_PMU->GPREG0 == 1) //came from deep power down
PDownDetected = 1;
LPC_PMU->PCON |= 0x00100; //PMU_PCON_SLEEPFLAG->reset le flag!!!!
LPC_PMU->PCON |= 0x00800; //PMU_PCON_DPDFLAG->reset le flag!!!!
LPC_PMU->DPDCTRL = 1; //enable hysterisis
LPC_PMU->DPDCTRL &= ~(1UL << 1); //Wake-up function is enable on pin PIO0_17
...
if (GPIO_ReadPin(IN_PWD_STATUS) == 0) //0 = normal mode and 1 means power down
{
...
}
else
{
(*romAPI)->pPWRD->power_mode_configure(3, 0); //DEEP_POWER_DOWN
__WFI();
}
}
Thx Victor for your helps :smileyhappy:
I found my problem (pointer location!!!) and i want to post it!!
In my file calcul.h, i have this code:
#define SLEEP 0
#define DEEP_SLEEP 1
#define POWER_DOWN 2
#define DEEP_POWER_DOWN 3
typedef struct PWRD_API {
void (*set_pll)(uint32_t cmd[], uint32_t resp[]); /*!< Set PLL function */
void (*set_power)(uint32_t cmd[], uint32_t resp[]); /*!< Set power function */
void (*power_mode_configure)(unsigned int mode, unsigned int peripheral);
void (*reserved1)();
void (*reserved2)();
} PWRD_API_T;
typedef struct _ROM {
const unsigned p_dev0;
const unsigned p_dev1;
const unsigned p_dev2;
const PWRD_API_T * pPWRD; /* ROM Power Management API */
const unsigned p_dev4;
const unsigned p_dev5;
const unsigned p_dev6;
const unsigned p_dev7;
} ROM_API;
and on my main.c
#include "calcul.h"
...
static ROM_API ** romAPI = (ROM_API **) 0x03000200; /* pointer to power API calls */
...
int main(void)
{
...
if (LPC_PMU->GPREG0 == 1) //came from deep power down
PDownDetected = 1;
LPC_PMU->PCON |= 0x00100; //PMU_PCON_SLEEPFLAG->reset le flag!!!!
LPC_PMU->PCON |= 0x00800; //PMU_PCON_DPDFLAG->reset le flag!!!!
LPC_PMU->DPDCTRL = 1; //enable hysterisis
LPC_PMU->DPDCTRL &= ~(1UL << 1); //Wake-up function is enable on pin PIO0_17
...
if (GPIO_ReadPin(IN_PWD_STATUS) == 0) //0 = normal mode and 1 means power down
{
...
}
else
{
(*romAPI)->pPWRD->power_mode_configure(3, 0); //DEEP_POWER_DOWN
__WFI();
}
}
It seems like the external pin PIO0_17 (WAKEUP pin) is not worked!!!!!
If i put a gnd on it, the lpc stays all the time in deep power down!!!
thx for your helps!!!
Hello Martin,
I took as an example the project periph_pmu of the LPCOpen v2_20 for the LPC1549. I modified this project in order to wake up the LPC with the pin PIO0_17 and I didn't face any problems, here is the main of my project.
int main(void)
{
/* Setup SystemCoreClock and any needed board code */
SystemCoreClockUpdate();
Board_Init();
Board_LED_Set(0, true);
/* Clear any previously set deep power down and sleep flags */
Chip_PMU_ClearSleepFlags(LPC_PMU, PMU_PCON_SLEEPFLAG | PMU_PCON_DPDFLAG);
DEBUGSTR("\r\n");
DEBUGSTR("-----------------------------------------------------------------\r\n");
DEBUGOUT("Power Control Example Cycle Count: \r\n");
DEBUGSTR(" System will go to DEEP POWER DOWN power state\r\n");
DEBUGSTR(" press SW1 to exit\r\n");
DEBUGSTR("-----------------------------------------------------------------\r\n\r\n");
if(0 == LPC_PMU->GPREG[0])
{
DEBUGSTR("-----------------------------------------------------------------\r\n");
DEBUGSTR(" Entering DEEP POWER DOWN power setting\r\n");
DEBUGOUT(" (System will exit DEEP POWER DOWN by pressing SW1)\r\n");
DEBUGSTR("-----------------------------------------------------------------\r\n\r\n");
LPC_PMU->GPREG[0] = 1;
delay();
Chip_PMU_DeepPowerDownState(LPC_PMU);
}
else
{
DEBUGSTR("-----------------------------------------------------------------\r\n");
DEBUGSTR(" System WAKE UP\r\n");
DEBUGOUT(" Led will start to Toggle\r\n");
DEBUGSTR("-----------------------------------------------------------------\r\n\r\n");
}
while (1)
{
Board_LED_Toggle(0);
delay();
}
return 0;
}
Also, I recommend you checking sections 4.4, 4.7.6, 4.7.6.2 and 4.7.6.3 of the user manual.
Hope it helps!
Victor.
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------