<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic LPC15xx sample multiple channels with software control in LPC Microcontrollers</title>
    <link>https://community.nxp.com/t5/LPC-Microcontrollers/LPC15xx-sample-multiple-channels-with-software-control/m-p/513304#M110</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by joepbrown on Sun Jan 24 22:20:09 MST 2016&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;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.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;My chip is the LPC1517. Before I init any of the ADC code I enable the fixed pins:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD bgcolor="#cacaca"&gt; &lt;PRE&gt;
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);

&lt;/PRE&gt; &lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I init the ADC:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD bgcolor="#cacaca"&gt; &lt;PRE&gt;
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);&lt;/PRE&gt; &lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;And in my ADC read function I try to return the single channel I'm trying to read:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD bgcolor="#cacaca"&gt; &lt;PRE&gt;
Chip_ADC_StartSequencer(LPC_ADC0, ADC_SEQA_IDX);
uint32_t sample = 0;
do
{
&amp;nbsp;&amp;nbsp;&amp;nbsp; sample = Chip_ADC_GetDataReg(LPC_ADC0,channel);
} while (!(sample &amp;amp; ADC_SEQ_GDAT_DATAVALID));
return ADC_DR_RESULT(sample);&lt;/PRE&gt; &lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;This works fine for channel ADC0_0 but all of the other channels are always 0.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;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.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Is there some sample code somewhere that shows how to sample multiple channels on the ADC sequencer?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 15 Jun 2016 17:05:25 GMT</pubDate>
    <dc:creator>lpcware</dc:creator>
    <dc:date>2016-06-15T17:05:25Z</dc:date>
    <item>
      <title>LPC15xx sample multiple channels with software control</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/LPC15xx-sample-multiple-channels-with-software-control/m-p/513304#M110</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by joepbrown on Sun Jan 24 22:20:09 MST 2016&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;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.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;My chip is the LPC1517. Before I init any of the ADC code I enable the fixed pins:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD bgcolor="#cacaca"&gt; &lt;PRE&gt;
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);

&lt;/PRE&gt; &lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I init the ADC:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD bgcolor="#cacaca"&gt; &lt;PRE&gt;
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);&lt;/PRE&gt; &lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;And in my ADC read function I try to return the single channel I'm trying to read:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD bgcolor="#cacaca"&gt; &lt;PRE&gt;
Chip_ADC_StartSequencer(LPC_ADC0, ADC_SEQA_IDX);
uint32_t sample = 0;
do
{
&amp;nbsp;&amp;nbsp;&amp;nbsp; sample = Chip_ADC_GetDataReg(LPC_ADC0,channel);
} while (!(sample &amp;amp; ADC_SEQ_GDAT_DATAVALID));
return ADC_DR_RESULT(sample);&lt;/PRE&gt; &lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;This works fine for channel ADC0_0 but all of the other channels are always 0.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;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.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Is there some sample code somewhere that shows how to sample multiple channels on the ADC sequencer?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Jun 2016 17:05:25 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/LPC15xx-sample-multiple-channels-with-software-control/m-p/513304#M110</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-15T17:05:25Z</dc:date>
    </item>
    <item>
      <title>Re: LPC15xx sample multiple channels with software control</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/LPC15xx-sample-multiple-channels-with-software-control/m-p/513305#M111</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by cgroen on Mon Jan 25 02:03:33 MST 2016&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;I run the ADC in interrupt, my setup code is like this:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD bgcolor="#cacaca"&gt; &lt;PRE&gt;
Chip_ADC_Init(LPC_ADC1, ADC_SEQA_IDX);
&amp;nbsp; Chip_ADC_SetClockRate(LPC_ADC1, ADC_MAX_SAMPLE_RATE);
Chip_ADC_SetupSequencer(LPC_ADC1, ADC_SEQA_IDX, 
(ADC_SEQ_CTRL_CHANSEL(0) | // AD1[0] P1.1 = Batt 1 current
 ADC_SEQ_CTRL_CHANSEL(9) | // AD1[9] P0.16 = Batt 2 current
 ADC_SEQ_CTRL_CHANSEL(8) | // AD1[8] P0.15 = VBUS sense
 ADC_SEQ_CTRL_CHANSEL(4) | // AD1[4] P1.2&amp;nbsp; = Batt 1 voltage
 ADC_SEQ_CTRL_CHANSEL(5) | // AD1[5] P1.3&amp;nbsp; = Batt 2 voltage
 ADC_SEQ_CTRL_MODE_EOS));&amp;nbsp; // We want interrupt on end of sequence
Chip_ADC_SetTrim(LPC_ADC1, ADC_TRIM_VRANGE_HIGHV);

// Disables pullups/pulldowns and disable digital mode
Chip_IOCON_PinMuxSet(LPC_IOCON, 1, 1,&amp;nbsp; IOCON_MODE_INACT);
Chip_IOCON_PinMuxSet(LPC_IOCON, 0, 16, IOCON_MODE_INACT);
Chip_IOCON_PinMuxSet(LPC_IOCON, 0, 15, IOCON_MODE_INACT);
Chip_IOCON_PinMuxSet(LPC_IOCON, 1, 2,&amp;nbsp; IOCON_MODE_INACT);
Chip_IOCON_PinMuxSet(LPC_IOCON, 1, 3,&amp;nbsp; IOCON_MODE_INACT);

// Assign AD channels to their pins via SWM (fixed pins)
Chip_SWM_EnableFixedPin(SWM_FIXED_ADC1_0); // P1.1
Chip_SWM_EnableFixedPin(SWM_FIXED_ADC1_9); // P0.16
Chip_SWM_EnableFixedPin(SWM_FIXED_ADC1_8); // P0.15
Chip_SWM_EnableFixedPin(SWM_FIXED_ADC1_4); // P1.2
Chip_SWM_EnableFixedPin(SWM_FIXED_ADC1_5); // P1.3

// Start calibration
&amp;nbsp; Chip_ADC_StartCalibration(LPC_ADC1);
while (!(Chip_ADC_IsCalibrationDone(LPC_ADC1))) OS_WAIT(10);

// Clear any pending interrupts
Chip_ADC_ClearFlags(LPC_ADC1, Chip_ADC_GetFlags(LPC_ADC1));

// Enable sequence A completion
Chip_ADC_EnableInt(LPC_ADC1, ADC_INTEN_SEQA_ENABLE);

NVIC_EnableIRQ(ADC1_SEQA_IRQn);

// Enable sequence A, will be started by thAD thread
Chip_ADC_EnableSequencer(LPC_ADC1, ADC_SEQA_IDX);
&lt;/PRE&gt; &lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;...and the interrupt routine:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD bgcolor="#cacaca"&gt; &lt;PRE&gt;
//-----------------------------------------------------------------------------
// IRQ handler for sequence A from AD converter
// Called when the sequence is completed
//-----------------------------------------------------------------------------
void ADC1_SEQA_IRQHandler(void) {
unsigned int pending;
// Get pending interrupts
pending = Chip_ADC_GetFlags(LPC_ADC1);

// Sequence A completion interrupt
if (pending &amp;amp; ADC_FLAGS_SEQA_INT_MASK) {
sequence1Complete = TRUE;
}
// Clear Sequence A completion interrupt
Chip_ADC_ClearFlags(LPC_ADC1, ADC_FLAGS_SEQA_INT_MASK);
}
&lt;/PRE&gt; &lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I then in a seperate thread read the results:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD bgcolor="#cacaca"&gt; &lt;PRE&gt;

// Start the process....&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
Chip_ADC_StartSequencer(LPC_ADC1, ADC_SEQA_IDX);

while (1) {
&amp;nbsp; // If ADC is complete, go start another conversion
if (sequence1Complete) {
sequence1Complete=FALSE;
// Read all channels (and filter)
adc_value[0]=filter(0, ADC_DR_RESULT(Chip_ADC_GetDataReg(LPC_ADC1, 0)));
adc_value[1]=filter(1, ADC_DR_RESULT(Chip_ADC_GetDataReg(LPC_ADC1, 9)));
adc_value[2]=filter(2, ADC_DR_RESULT(Chip_ADC_GetDataReg(LPC_ADC1, 8)));
adc_value[3]=filter(3, ADC_DR_RESULT(Chip_ADC_GetDataReg(LPC_ADC1, 4)));
adc_value[4]=filter(4, ADC_DR_RESULT(Chip_ADC_GetDataReg(LPC_ADC1, 5)));
// Start another conversion
Chip_ADC_StartSequencer(LPC_ADC1, ADC_SEQA_IDX);
}
&amp;nbsp; .. do other stuff etc
&amp;nbsp; ..

}



&lt;/PRE&gt; &lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Hope this helps ?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Jun 2016 17:05:26 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/LPC15xx-sample-multiple-channels-with-software-control/m-p/513305#M111</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-15T17:05:26Z</dc:date>
    </item>
    <item>
      <title>Re: LPC15xx sample multiple channels with software control</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/LPC15xx-sample-multiple-channels-with-software-control/m-p/513306#M112</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by joepbrown on Tue Jan 26 10:31:12 MST 2016&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks for the reply. With your example I was able to get my code fixed by swapping the order of initialization around and adding the &lt;/SPAN&gt;&lt;STRONG&gt;Chip_ADC_SetTrim()&lt;/STRONG&gt;&lt;SPAN&gt; function.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;One note: I think the second parameter in your init line &lt;/SPAN&gt;&lt;STRONG&gt;Chip_ADC_Init(LPC_ADC1, &lt;I&gt;ADC_SEQA_IDX&lt;/I&gt;);&lt;/STRONG&gt;&lt;SPAN&gt; is incorrect. The init function takes some flags and &lt;/SPAN&gt;&lt;STRONG&gt;ADC_SEQA_IDX&lt;/STRONG&gt;&lt;SPAN&gt; is just an enum. I don't think it matters since SEQA_IDX is just 0, but it's something you may want to correct.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Here is my code if anyone is interested. I configure the pins for &lt;/SPAN&gt;&lt;STRONG&gt;IOCON_MODE_INACT&lt;/STRONG&gt;&lt;SPAN&gt; and enabled the fixed pin before the init is called.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD bgcolor="#cacaca"&gt; &lt;PRE&gt;void Adc::Init(Hw::Pin p)
{
&amp;nbsp;&amp;nbsp;&amp;nbsp; channel = p.adc;
&amp;nbsp;&amp;nbsp;&amp;nbsp; if (!setup)
&amp;nbsp;&amp;nbsp;&amp;nbsp; {
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Chip_ADC_Init(LPC_ADC0, 0);
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Chip_ADC_SetClockRate(LPC_ADC0, ADC_MAX_SAMPLE_RATE / 4);
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Chip_ADC_SetupSequencer(LPC_ADC0, ADC_SEQA_IDX,ADC_SEQ_CTRL_CHANSEL(channel));
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Chip_ADC_SetTrim(LPC_ADC0,ADC_TRIM_VRANGE_LOWV);
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Chip_ADC_StartCalibration(LPC_ADC0);
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; while (!(Chip_ADC_IsCalibrationDone(LPC_ADC0)));
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Chip_ADC_ClearFlags(LPC_ADC0, Chip_ADC_GetFlags(LPC_ADC0));
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Chip_ADC_EnableSequencer(LPC_ADC0, ADC_SEQA_IDX);
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; setup = true;
&amp;nbsp;&amp;nbsp;&amp;nbsp; }
&amp;nbsp;&amp;nbsp;&amp;nbsp; else
&amp;nbsp;&amp;nbsp;&amp;nbsp; {
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Chip_ADC_DisableSequencer(LPC_ADC0,ADC_SEQA_IDX);
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Chip_ADC_SetSequencerBits(LPC_ADC0,ADC_SEQA_IDX,ADC_SEQ_CTRL_CHANSEL(channel));
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Chip_ADC_EnableSequencer(LPC_ADC0, ADC_SEQA_IDX);
&amp;nbsp;&amp;nbsp;&amp;nbsp; }
}

uint16_t Adc::Read(void)
{
&amp;nbsp;&amp;nbsp;&amp;nbsp; Chip_ADC_StartSequencer(LPC_ADC0, ADC_SEQA_IDX);
&amp;nbsp;&amp;nbsp;&amp;nbsp; uint32_t sample = 0;
&amp;nbsp;&amp;nbsp;&amp;nbsp; uint32_t timeout = scheduler.Millis() + 10;
&amp;nbsp;&amp;nbsp;&amp;nbsp; do
&amp;nbsp;&amp;nbsp;&amp;nbsp; {
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; sample = Chip_ADC_GetDataReg(LPC_ADC0,channel);
&amp;nbsp;&amp;nbsp;&amp;nbsp; } while (!(sample &amp;amp; ADC_DR_DATAVALID) &amp;amp;&amp;amp; timeout &amp;gt; scheduler.Millis());
&amp;nbsp;&amp;nbsp;&amp;nbsp; sample = (ADC_DR_RESULT(sample) * 3300) / 4095;
&amp;nbsp;&amp;nbsp;&amp;nbsp; return sample;
}&lt;/PRE&gt; &lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Jun 2016 17:05:26 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/LPC15xx-sample-multiple-channels-with-software-control/m-p/513306#M112</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-15T17:05:26Z</dc:date>
    </item>
    <item>
      <title>Re: LPC15xx sample multiple channels with software control</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/LPC15xx-sample-multiple-channels-with-software-control/m-p/513307#M113</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by cgroen on Tue Jan 26 11:18:48 MST 2016&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks Joe,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;you are absolutely right about the call to Chip_ADC_init!&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Why I had that in the first place I don't know, guess it must have been a copy/paste brain short here &lt;SPAN class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;&lt;LI-EMOJI id="lia_slightly-smiling-face" title=":slightly_smiling_face:"&gt;&lt;/LI-EMOJI&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks for pointing it out (as you wrote, the value was 0 anyway, but still it was an error to mix the ADC_SEQA_IDX into that call!)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD bgcolor="#cacaca"&gt; &lt;PRE&gt;
Chip_ADC_Init(LPC_ADC1, &lt;STRONG&gt;0&lt;/STRONG&gt;);
&amp;nbsp; Chip_ADC_SetClockRate(LPC_ADC1, ADC_MAX_SAMPLE_RATE);
Chip_ADC_SetupSequencer(LPC_ADC1, ADC_SEQA_IDX, 
(ADC_SEQ_CTRL_CHANSEL(0) | // AD1[0] P1.1 = Batt 1 current
 ADC_SEQ_CTRL_CHANSEL(9) | // AD1[9] P0.16 = Batt 2 current
 ADC_SEQ_CTRL_CHANSEL(8) | // AD1[8] P0.15 = VBUS sense
 ADC_SEQ_CTRL_CHANSEL(4) | // AD1[4] P1.2&amp;nbsp; = Batt 1 voltage
 ADC_SEQ_CTRL_CHANSEL(5) | // AD1[5] P1.3&amp;nbsp; = Batt 2 voltage
 ADC_SEQ_CTRL_MODE_EOS));&amp;nbsp; // We want interrupt on end of sequence
Chip_ADC_SetTrim(LPC_ADC1, ADC_TRIM_VRANGE_HIGHV);

// Disables pullups/pulldowns and disable digital mode
Chip_IOCON_PinMuxSet(LPC_IOCON, 1, 1,&amp;nbsp; IOCON_MODE_INACT);
Chip_IOCON_PinMuxSet(LPC_IOCON, 0, 16, IOCON_MODE_INACT);
Chip_IOCON_PinMuxSet(LPC_IOCON, 0, 15, IOCON_MODE_INACT);
Chip_IOCON_PinMuxSet(LPC_IOCON, 1, 2,&amp;nbsp; IOCON_MODE_INACT);
Chip_IOCON_PinMuxSet(LPC_IOCON, 1, 3,&amp;nbsp; IOCON_MODE_INACT);

&lt;/PRE&gt; &lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Jun 2016 17:05:27 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/LPC15xx-sample-multiple-channels-with-software-control/m-p/513307#M113</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-15T17:05:27Z</dc:date>
    </item>
  </channel>
</rss>

