ADC channel 4 problem

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

ADC channel 4 problem

898 Views
lpcware
NXP Employee
NXP Employee
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
Labels (1)
0 Kudos
6 Replies

664 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Franky on Wed Oct 29 11:21:41 MST 2014
Thanks for your answers LabRat.

The hardware (PCB design) seems to be OK. I tried to wire both uC analog pins (channel4 & channel5) with the same signal, so the c-5 values are OK, but c-4 values are faulty. I even changed the uC but the problem persist. Maybe there is problem in faulty production uC serie or there is some problem in enabled periphery combination.

I run some aditional tests and found out that by reducing reading time (reading time is slower) reduces faulty ADC values on channel 4.    
0 Kudos

664 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by LabRat on Wed Oct 29 07:43:15 MST 2014

Quote: Franky
No other ideas?



Check your hardware and software...

The (corrected) code snippet you've posted is working fine here (at least with a working hardware and correct setup).

So everything I can say is that this 5 lines are not your problem 

LPC_ADC->ADCR &= 0xFFFFFF00;
LPC_ADC->ADCR |= 0x01000010;
while (!(LPC_ADC->ADSTAT & 0x00000010));
LPC_ADC->ADCR &= 0xF8FFFFFF;
ADC_TEMP1 = ((LPC_ADC->ADDR4 >> 4) & 0xFFF);
0 Kudos

664 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Franky on Wed Oct 29 06:59:55 MST 2014
No other ideas?
0 Kudos

664 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Franky on Tue Oct 28 04:45:39 MST 2014
And LPC_ADC->ADDR5 is my fault by copy/paste, sorry. The address is LPC_ADC->ADDR4 by channel 4.
0 Kudos

664 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Franky on Tue Oct 28 04:43:44 MST 2014
I checked the pin configuration and found no error. I use keil uvision and the debug function shows that the pin is configured as AIN4. See the attachment.
0 Kudos

664 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by LabRat on Tue Oct 28 04:36:25 MST 2014
Pin function?


Quote: Franky
// 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 = (([color=#f00]LPC_ADC->ADDR5 [/color]>> 4) & 0xFFF);
}



And ADDR5 doesn't look correct...
0 Kudos