lpcware

LPC15xx sample multiple channels with software control

Discussion created by lpcware Employee on Jun 15, 2016
Latest reply on Jun 15, 2016 by lpcware
Content originally posted in LPCWare by joepbrown on Sun Jan 24 22:20:09 MST 2016
I'm trying to sample ADC0_0 through ADC0_5 via software trigger but for some reason I can only read valid data from ADC0_0.

My chip is the LPC1517. Before I init any of the ADC code I enable the fixed pins:


Chip_IOCON_PinMuxSet(LPC_IOCON,0,8,IOCON_MODE_INACT);
Chip_SWM_EnableFixedPin(SWM_FIXED_ADC0_0);
Chip_IOCON_PinMuxSet(LPC_IOCON,0,7,IOCON_MODE_INACT);
Chip_SWM_EnableFixedPin(SWM_FIXED_ADC0_1);
Chip_IOCON_PinMuxSet(LPC_IOCON,0,6,IOCON_MODE_INACT);
Chip_SWM_EnableFixedPin(SWM_FIXED_ADC0_2);
Chip_IOCON_PinMuxSet(LPC_IOCON,0,5,IOCON_MODE_INACT);
Chip_SWM_EnableFixedPin(SWM_FIXED_ADC0_3);
Chip_IOCON_PinMuxSet(LPC_IOCON,0,4,IOCON_MODE_INACT);
Chip_SWM_EnableFixedPin(SWM_FIXED_ADC0_4);
Chip_IOCON_PinMuxSet(LPC_IOCON,0,3,IOCON_MODE_INACT);
Chip_SWM_EnableFixedPin(SWM_FIXED_ADC0_5);



I init the ADC:


Chip_ADC_Init(LPC_ADC0, 0);
Chip_ADC_StartCalibration(LPC_ADC0);
while (!(Chip_ADC_IsCalibrationDone(LPC_ADC0)));
Chip_ADC_SetClockRate(LPC_ADC0, ADC_MAX_SAMPLE_RATE / 4);
Chip_ADC_DisableSequencer(LPC_ADC0,ADC_SEQA_IDX);
Chip_ADC_SetSequencerBits(LPC_ADC0,ADC_SEQA_IDX,(0x3F | ADC_SEQ_CTRL_MODE_EOS));
Chip_ADC_ClearFlags(LPC_ADC0, Chip_ADC_GetFlags(LPC_ADC0));
Chip_ADC_EnableSequencer(LPC_ADC0, ADC_SEQA_IDX);


And in my ADC read function I try to return the single channel I'm trying to read:


Chip_ADC_StartSequencer(LPC_ADC0, ADC_SEQA_IDX);
uint32_t sample = 0;
do
{
    sample = Chip_ADC_GetDataReg(LPC_ADC0,channel);
} while (!(sample & ADC_SEQ_GDAT_DATAVALID));
return ADC_DR_RESULT(sample);


This works fine for channel ADC0_0 but all of the other channels are always 0.

I have eliminated the hardware as the problem (can trance every pin on the board and verify the voltage). I've tried different ADC modes (BURST, SINGLESTEP) and it doesn't make a difference.

Is there some sample code somewhere that shows how to sample multiple channels on the ADC sequencer?

Outcomes