lpcware

After adding a Deep Power Down Mode my code stopped functioning

Discussion created by lpcware Employee on Jun 15, 2016
Latest reply on Jun 15, 2016 by lpcware
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?

Outcomes