lpcware

ADC channel 4 problem

Discussion created by lpcware Employee on Jun 15, 2016
Latest reply on Jun 15, 2016 by lpcware
Content originally posted in LPCWare by Franky on Tue Oct 28 03:52:17 MST 2014
Hello

On my current project I have encountered some problems on the ADC conversation on channel 4. I use microcontroller LPC1768. The ADC is used for motor current sensing every 1ms. The ADC clock is 10MHz.
The ADC channel 4 gives me wrong values. The voltage on pin is around 20mV and the ADC value is sometimes 0xFFF (maximum value). The voltage is measured with oscilloscope, so there are no peaks in voltage. I tried with other ADC channels but they are OK – I receive right values with the same conditions as channel 4.   
Is there something wrong in ADC channel 4 hardware or I have some bug in code. Here is piece of code:

// test on ADC channel 4 (wrong ADC values)
void EC5_MOTOR_CURRENT (void)  
{
LPC_ADC->ADCR &= 0xFFFFFF00;
LPC_ADC->ADCR |= 0x01000010;
while (!(LPC_ADC->ADSTAT & 0x00000010));
LPC_ADC->ADCR &= 0xF8FFFFFF;
ADC_TEMP1 = ((LPC_ADC->ADDR5 >> 4) & 0xFFF);
}

// test on ADC channel 5 (reading OK)
void EC5_MOTOR_CURRENT (void)  
{
LPC_ADC->ADCR &= 0xFFFFFF00;
LPC_ADC->ADCR |= 0x01000020;
while (!(LPC_ADC->ADSTAT & 0x00000020));
LPC_ADC->ADCR &= 0xF8FFFFFF;
ADC_TEMP1 = ((LPC_ADC->ADDR5 >> 4) & 0xFFF);
}

Best regards

Outcomes