AnsweredAssumed Answered

LPC822 ADC sequence wrong values

Question asked by Alexander Hoet on Oct 3, 2016
Latest reply on Oct 7, 2016 by Werner Fritsch

Hi,

 

I have a problem using the sequences of the LPC822.

 

When I select multiple channels to be read in a sequence and I select single step everything is fine and the correct values are read. However when disabling single step one channel (10)  gives me wrong values. The incorrect value is consistent though, it wil always be the same incorrect value.

 

Anyone got any idea what this could possibly be? Source code down below. A convertion is triggered manually by the MRT every 100ms.

 

Thx,

 

Alexander

 

void Init_adc(void)
{
/* Power up ADC and enable ADC clock */
Chip_SYSCTL_PowerUp(SYSCTL_SLPWAKE_ADC_PD);
Chip_Clock_EnablePeriphClock(SYSCTL_CLOCK_ADC);

 

/* Perform ADC calibration */
LPC_ADC->CTRL = ADC_CR_CLKDIV((SystemCoreClock / 500000) - 1) | ADC_CR_CALMODEBIT;
while((LPC_ADC->CTRL & ADC_CR_CALMODEBIT) != 0); // Wait until the CALLMODE bit clears

 

/* Set the ADC clock divider for maximum speed */
LPC_ADC->CTRL = ADC_CR_CLKDIV(0);

 

/* Configure SEQA as to read the current, temperature and voltage */
LPC_ADC->SEQ_CTRL[0] = ADC_SEQ_CTRL_CHANSEL(3) | ADC_SEQ_CTRL_CHANSEL(10) | ADC_SEQ_CTRL_CHANSEL(11);

 

/* Trigger polarity is positive edge */
LPC_ADC->SEQ_CTRL[0] |= ADC_SEQ_CTRL_HWTRIG_POLPOS;

 

/* Interrupt at end of sequence */
LPC_ADC->SEQ_CTRL[0] |= ADC_SEQ_CTRL_MODE_EOS;

 

/* Enable SEQA */
LPC_ADC->SEQ_CTRL[0] |= ADC_SEQ_CTRL_SEQ_ENA;

 

/* Enable interrupts for SEQA */

LPC_ADC->INTEN = ADC_INTEN_SEQA_ENABLE;
NVIC_EnableIRQ(ADC_SEQA_IRQn);
}

 

 

void ADC_SEQA_IRQHandler(void)
{

state.current = CONVERT_ADC_CURRENT(ADC_DR_RESULT(LPC_ADC->DR[3]));
state.temperature = CONVERT_ADC_TEMPERATURE(ADC_DR_RESULT(LPC_ADC->DR[10]));
state.voltage = CONVERT_ADC_VOLTAGE(ADC_DR_RESULT(LPC_ADC->DR[11]));
}

Outcomes