ADC Burst mode

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

ADC Burst mode

688 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by nkarakotas on Mon May 07 22:59:39 MST 2012
Hello,

I have made a capacitive sense board and im trying to do a burst read rather than polling the ADC channels but it seems only the first channel gives me a correct reading the rest are erroneous. When I do polling I get correct conversions. Here is the burst channel code as soon I enable more than one channel I have problems. Could it be because of the switch of pins from digital to analogue?

static uint16_t Sense(uint16_t *val){

PINSEL_CFG_Type PinCfg;
    /* ADC Pin select
       * P0.23 as AD0.0
       */
uint32_t reading = 0;

PinCfg.OpenDrain = 0;
PinCfg.Portnum = 0;
PinCfg.Funcnum = 1;
PinCfg.Pinmode = 2; //Pin has neither pull-up nor pull-down
PinCfg.Pinnum = 23;
PINSEL_ConfigPin(&PinCfg);
PinCfg.Pinnum = 24;
PINSEL_ConfigPin(&PinCfg);
PinCfg.Pinnum = 25;
PINSEL_ConfigPin(&PinCfg);
PinCfg.Pinnum = 26;
PINSEL_ConfigPin(&PinCfg);


    ADC_ChannelCmd(LPC_ADC,0,ENABLE);
    ADC_ChannelCmd(LPC_ADC,1,ENABLE);
    ADC_ChannelCmd(LPC_ADC,2,ENABLE);
    ADC_ChannelCmd(LPC_ADC,3,ENABLE);


    ADC_BurstCmd(LPC_ADC,1);
 //   while(!ADC_GlobalGetStatus(LPC_ADC,0));
    volatile uint32_t ad;
    do {
    ad = LPC_ADC->ADDR0;
    } while ((ad & ADC_DR_DONE_FLAG) == 0);
    val[0] = ADC_DR_RESULT(ad);

    do {
    ad = LPC_ADC->ADDR1;
    } while ((ad & ADC_DR_DONE_FLAG) == 0);
    val[1] = ADC_DR_RESULT(ad);

    do {
    ad = LPC_ADC->ADDR2;
    } while ((ad & ADC_DR_DONE_FLAG) == 0);
    val[2] = ADC_DR_RESULT(ad);

    do {
    ad = LPC_ADC->ADDR3;
    } while ((ad & ADC_DR_DONE_FLAG) == 0);
    val[3] = ADC_DR_RESULT(ad);


    ADC_BurstCmd(LPC_ADC,0);

    ADC_ChannelCmd(LPC_ADC,0,DISABLE);
    ADC_ChannelCmd(LPC_ADC,1,DISABLE);
    ADC_ChannelCmd(LPC_ADC,2,DISABLE);
    ADC_ChannelCmd(LPC_ADC,3,DISABLE);

PinCfg.Funcnum = 0;
PinCfg.OpenDrain = 0;
PinCfg.Pinmode = 0; //Pin has neither pull-up nor pull-down
PinCfg.Pinnum = 23; // start pin is 23 -> AD0
PinCfg.Portnum = 0;
PINSEL_ConfigPin(&PinCfg);
PinCfg.Pinnum = 24; // start pin is 23 -> AD0
PINSEL_ConfigPin(&PinCfg);
PinCfg.Pinnum = 25; // start pin is 23 -> AD0
PINSEL_ConfigPin(&PinCfg);
PinCfg.Pinnum = 26; // start pin is 23 -> AD0
PINSEL_ConfigPin(&PinCfg);

    GPIO_SetDir(0, 1<<23, 1);
    GPIO_SetValue(0, 1<<23);
    GPIO_SetDir(0, 1<<24, 1);
    GPIO_SetValue(0, 1<<24);
    GPIO_SetDir(0, 1<<25, 1);
    GPIO_SetValue(0, 1<<25);
    GPIO_SetDir(0, 1<<26, 1);
    GPIO_SetValue(0, 1<<26);


    return reading;

}
0 Kudos
Reply
2 Replies

513 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by nkarakotas on Tue May 08 11:27:12 MST 2012
Sorry,

LPC1769.
0 Kudos
Reply

513 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by frame on Tue May 08 11:24:37 MST 2012
You mentioned no particular controller.
The following sources might help you:
http://mbed.org/forum/mbed/topic/2003/
http://mbed.org/forum/mbed/topic/1798/?page=1
0 Kudos
Reply