After adding a Deep Power Down Mode my code stopped functioning

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

After adding a Deep Power Down Mode my code stopped functioning

337 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by lab1 on Fri Apr 04 02:23:34 MST 2014
This is my original code that must switched on and off a diode based ADC value
Chip lpc11c14
#include "chip.h"

int k;

const uint32_t OscRateIn = 12000000;
static ADC_CLOCK_SETUP_T ADCSetup;

static void Init_ADC_PinMux(void)
{
Chip_IOCON_PinMuxSet(LPC_IOCON, IOCON_PIO1_0, FUNC2);
}

void Chip_GPIO_Init(LPC_GPIO_T *pGPIO)
{
Chip_Clock_EnablePeriphClock(SYSCTL_CLOCK_GPIO);
}
int main(void) {

uint16_t dataADC;
int j;
//Chip_GPIO_Init(LPC_GPIO);
volatile static int h = 0 ;
volatile static int l = 1000 ;
Init_ADC_PinMux();

/* ADC Init */
Chip_ADC_Init(LPC_ADC, &ADCSetup);
Chip_ADC_EnableChannel(LPC_ADC, ADC_CH1, ENABLE);

    while(1) {
    j = 50000;

    while (j--) {
    /* Start A/D conversion */
    Chip_ADC_SetStartMode(LPC_ADC, ADC_START_NOW, ADC_TRIGGERMODE_RISING);

    /* Waiting for A/D conversion complete */
    while (Chip_ADC_ReadStatus(LPC_ADC, ADC_CH1, ADC_DR_DONE_STAT) != SET) {}

    /* Read ADC value */
    Chip_ADC_ReadValue(LPC_ADC, ADC_CH1, &dataADC);

    if (h<dataADC) {
    hoe=dataADC;
         }
    if(l>dataADC){
    l=dataADC;
         }
    }

    if(h>200){
    Chip_GPIO_SetPinDIROutput(LPC_GPIO, 3, 2);
    Chip_GPIO_SetPinDIRInput(LPC_GPIO, 3, 1);
    }
    
    if(l<200){
    Chip_GPIO_SetPinDIROutput(LPC_GPIO, 3, 1);
    Chip_GPIO_SetPinDIRInput(LPC_GPIO, 3, 2);
    }

    h = 0;
    l = 1000;
    }
}


So I add this code to use Deep Power Down Mode
LPC_PMU->PCON= (1<<1)|(1<<11);
SCB->SCR|=(1<<2);//Set SLEEPDEEP bit
LPC_SYSCTL->PDRUNCFG &= ~((1<<0) | (1<<1));
__WFI();


This gives me this code

#include "chip.h"

int k;

const uint32_t OscRateIn = 12000000;
static ADC_CLOCK_SETUP_T ADCSetup;

static void Init_ADC_PinMux(void)
{
Chip_IOCON_PinMuxSet(LPC_IOCON, IOCON_PIO1_0, FUNC2);
}

void Chip_GPIO_Init(LPC_GPIO_T *pGPIO)
{
Chip_Clock_EnablePeriphClock(SYSCTL_CLOCK_GPIO);
}
int main(void) {

uint16_t dataADC;
int j;
//Chip_GPIO_Init(LPC_GPIO);
volatile static int h = 0 ;
volatile static int l = 1000 ;
Init_ADC_PinMux();

/* ADC Init */
Chip_ADC_Init(LPC_ADC, &ADCSetup);
Chip_ADC_EnableChannel(LPC_ADC, ADC_CH1, ENABLE);

    while(1) {
    

    LPC_PMU->PCON= (1<<1)|(1<<11);
    SCB->SCR|=(1<<2);//Set SLEEPDEEP bit
    LPC_SYSCTL->PDRUNCFG &= ~((1<<0) | (1<<1));

    j = 50000;

    while (j--) {
    /* Start A/D conversion */
    Chip_ADC_SetStartMode(LPC_ADC, ADC_START_NOW, ADC_TRIGGERMODE_RISING);

    /* Waiting for A/D conversion complete */
    while (Chip_ADC_ReadStatus(LPC_ADC, ADC_CH1, ADC_DR_DONE_STAT) != SET) {}

    /* Read ADC value */
    Chip_ADC_ReadValue(LPC_ADC, ADC_CH1, &dataADC);

    /* Print ADC value */


    if (h<dataADC) {
    hoe=dataADC;
    }
    if(l>dataADC){
    l=dataADC;
    }
    }


    if(h>200){
    Chip_GPIO_SetPinDIROutput(LPC_GPIO, 3, 2);
    Chip_GPIO_SetPinDIRInput(LPC_GPIO, 3, 1);
    }

    
    if(l<200){

    Chip_GPIO_SetPinDIROutput(LPC_GPIO, 3, 1);
    Chip_GPIO_SetPinDIRInput(LPC_GPIO, 3, 2);

    }

    h = 0;
    l = 1000;
    __WFI();

    }
}


My problem is that when I added Deep Power Down Mode, the program stops after a passage of my loop.
Does anyone know why this is happening?
Labels (1)
0 Kudos
2 Replies

305 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by nxp_apps on Mon Apr 07 11:40:31 MST 2014
Hi,

Once you enter deep power-down mode, code execution will stop as expected. You will have to use the wake-up pin to wake the device.
For deep power-down mode, upon wakeup, the device goes through a reset process.

Thanks.

nxp_support
0 Kudos

305 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by pgr on Fri Apr 04 09:01:43 MST 2014
WFI stand for Wait For Interrupt, so when executing this instruction you say to your processor to sleep until the next interrupt.
As you have no interrupt the CPU sleep for ever. You have to use a timer or SysTick to generate an interrupt after a while to wake-up your CPU...

0 Kudos