LPC1833 Strange ADC behavier

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

LPC1833 Strange ADC behavier

484 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by hamu on Fri Nov 15 01:13:35 MST 2013
Hello,

I want to convert all 8 ADC channels but the behavier is not as expected.

Example (V_ref = 2.5V):
Reading channel 5 with the CMSIS funcions

<code>
ADC_ChannelCmd (LPC_ADC0, 5, 1);
ADC_StartCmd(LPC_ADC0, 1);
while(!ADC_ChannelGetStatus(LPC_ADC0, 5, 1));
Value1 = ADC_ChannelGetData(LPC_ADC0, 5);
ADC_ChannelCmd (LPC_ADC0, 5, 0);
</code>

The result is always 0x3FF althought the value on the pin is 0,398V. With burst mode the conversion delivers the same result.
If I convert more than one channel in burst mode the conversion results depends on the number of activated channels. If I convert only channel 5 I get 0x3FF but when I convert channel 0 and channel 5 the conversion value for channel 5 is 0x190 (with same voltages on the pins).

Has anyone a working sample for the ADC??

Thanks
Thomas
Labels (1)
0 Kudos
Reply
1 Reply

423 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Pacman on Fri Nov 15 13:36:08 MST 2013
I don't think those library functions are CMSIS; they're written by NXP.

Are you sure your ADC is actually measuring anything at all ?
If the result from your read operation is always the same number, I'd say that your ADC is not reading anything.
If the results vary slightly even for the same voltage, it's probably working.
But let's look at the code...

When using the library functions, please use the definitions that belong to them as parameters.
For instance:
ADC_ChannelCmd (LPC_ADC0, 5, 1);
ADC_StartCmd(LPC_ADC0, 1);
while(!ADC_ChannelGetStatus(LPC_ADC0, 5, 1));
Value1 = ADC_ChannelGetData(LPC_ADC0, 5);
ADC_ChannelCmd (LPC_ADC0, 5, 0);



ADC_Init(LPC_ADC0,400000);
ADC_ChannelCmd(LPC_ADC0, 5, ENABLE);
ADC_StartCmd(LPC_ADC0, ADC_START_NOW);
while(!ADC_ChannelGetStatus(LPC_ADC0, 5, ADC_DATA_DONE));
Value1 = ADC_ChannelGetData(LPC_ADC0, 5);
ADC_ChannelCmd (LPC_ADC0, 5, ADC_START_CONTINUOUS);


...See anything missing or anything that you don't think should be there ?
It's a good idea to put a comment on the right of each line, which says what you intend the line to do.

Also, do you switch your pin configurations to use the ADC ?
If not, they'll never measure anything useful.

Please also wrap your code-snippets in the [color=#030][[/color][color=#030]code][/color] / [color=#030][[/color][color=#030]/code][/color] tags.
0 Kudos
Reply