Non working ADC on LPC824

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

Non working ADC on LPC824

431 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by remcopoelstra on Thu Mar 12 02:58:14 MST 2015
Hi,

I'm trying to get the ADC on the LPC824. I currently apply either 0V or 3V3 on channel 0, but as a result I always get back a value in the range 0x20-0x30.
Enabled the channel 0 pin in SWM.
I've enabled power and clock to the ADC.
Run the calibration.
Setup a clock of 500kHz
Enabled a burst sequence.
Since my source has quite a high impedance (1kOhm), I see the ripple of the ADC on the signal and it's 20kHz, as expected.
In the debugger I see that the values in the data registers get updated all the time, but the range is always 0x20-0x30.
I checked VREFP and VREFN and they are 3V3 and 0V.

Condensed code:
Chip_SWM_EnableFixedPin(SWM_FIXED_ADC0);
Chip_ADC_Init(LPC_ADC,0); //This will enable power and clock
Chip_ADC_StartCalibration(LPC_ADC);
while(!Chip_ADC_IsCalibrationDone(LPC_ADC));
Chip_ADC_SetClockRate(LPC_ADC,500000); //500kHz
Chip_ADC_SetupSequencer(LPC_ADC,ADC_SEQA_IDX,
ADC_SEQ_CTRL_CHANSEL(0)|
ADC_SEQ_CTRL_MODE_EOS);
Chip_ADC_EnableSequencer(LPC_ADC,ADC_SEQA_IDX);
Chip_ADC_StartBurstSequencer(LPC_ADC,ADC_SEQA_IDX);


What am I doing wrong? Did I miss something?

Thanks in advance.

Kind regards,

Remco Poelstra
Labels (1)
0 Kudos
2 Replies

268 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by remcopoelstra on Thu Mar 12 06:13:46 MST 2015
Hi,

Thanks for your reply. Seems my code was a bit too condensed. I do enable clocks to the SWM and in the debugger all registers have the values they should have. Since the analog waveform contains noise from the ADC process I believe the pin setup is correct.

Regards,

Remco Poelstra
0 Kudos

268 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by starblue on Thu Mar 12 05:08:19 MST 2015
You need to enable the clock for SWM first (you can disable it after setup is complete). Maybe some other clocks, too.
0 Kudos