<?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>LPC MicrocontrollersのトピックProblems with ADC conversion</title>
    <link>https://community.nxp.com/t5/LPC-Microcontrollers/Problems-with-ADC-conversion/m-p/559924#M15976</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by ledi007 on Tue Apr 19 07:02:19 MST 2016&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;Hello,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;i do my first steps with an LPC822 and would like to make a simple ADC conversion @ ADC_2 pin.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I wrote this code for initialization and basically the code works, but the result is wrong.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;On ADC_2 (pin PIO_14) i had connected a poti between Vcc and GND. As result i get only the value 0 and 4095.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Every 200ms i start an adc conversion in the SysTick_Handler and in the endless loop i read the adc data register of channel 2.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I hope, someone can help me ?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Here is my code:&lt;/SPAN&gt;&lt;BR /&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD bgcolor="#cacaca"&gt; &lt;PRE&gt;
#include "chip.h"
#include &amp;lt;cr_section_macros.h&amp;gt;

void SysTick_Handler(void)
{
LPC_GPIO_PORT-&amp;gt;NOT[0] = (1&amp;lt;&amp;lt;15);// Toggle PIO0_15
Chip_ADC_StartSequencer(LPC_ADC, ADC_SEQA_IDX);// manual start for ADC conversion sequence A
}

int main(void)
{
uint32_t rawSample, ADC_result;

Chip_SystemInit();// setup system clocking
SystemCoreClockUpdate();// Read clock settings and update SystemCoreClock variable
&amp;nbsp;&amp;nbsp;&amp;nbsp; SysTick_Config(SystemCoreClock / 5);// Systick is reloading 1/5 of a second = 200ms...

&amp;nbsp;&amp;nbsp;&amp;nbsp; LPC_GPIO_PORT-&amp;gt;DIR[0] |= (1&amp;lt;&amp;lt;15); // Set direction of PIO0_15 to output

&amp;nbsp;&amp;nbsp;&amp;nbsp; Chip_ADC_Init(LPC_ADC,0);// setup ADC 12-bit mode, normal power
&amp;nbsp;&amp;nbsp;&amp;nbsp; Chip_ADC_StartCalibration(LPC_ADC);// calibration after ADC initialization
&amp;nbsp;&amp;nbsp;&amp;nbsp; while (!(Chip_ADC_IsCalibrationDone(LPC_ADC))) {}

&amp;nbsp;&amp;nbsp;&amp;nbsp; Chip_ADC_SetClockRate(LPC_ADC, ADC_MAX_SAMPLE_RATE);
&amp;nbsp;&amp;nbsp;&amp;nbsp; Chip_ADC_SetupSequencer(LPC_ADC, ADC_SEQA_IDX, (ADC_SEQ_CTRL_CHANSEL(2) | ADC_SEQ_CTRL_MODE_EOS)); // setup SEQA, ADC_CH2
&amp;nbsp;&amp;nbsp;&amp;nbsp; Chip_Clock_EnablePeriphClock(SYSCTL_CLOCK_SWM); // enable the clock to the switch matrix
&amp;nbsp;&amp;nbsp;&amp;nbsp; Chip_SWM_EnableFixedPin(SWM_FIXED_ADC2);// config the switch matrix&amp;nbsp; for PIO0_14 as the input for ADC_2
&amp;nbsp;&amp;nbsp;&amp;nbsp; Chip_Clock_DisablePeriphClock(SYSCTL_CLOCK_SWM); // disable the clock to the switch matrix to save power
&amp;nbsp;&amp;nbsp;&amp;nbsp; Chip_ADC_EnableSequencer(LPC_ADC, ADC_SEQA_IDX);// enable sequencer

&amp;nbsp;&amp;nbsp;&amp;nbsp; while(1)
&amp;nbsp;&amp;nbsp;&amp;nbsp; {
&amp;nbsp;&amp;nbsp;&amp;nbsp; rawSample = Chip_ADC_GetDataReg(LPC_ADC, 2);// read ADC data register of ADC channel 2
&amp;nbsp;&amp;nbsp;&amp;nbsp; ADC_result = (rawSample &amp;gt;&amp;gt; 4) &amp;amp; 0xFFF;&amp;nbsp; // getting adc converted result from 4th to 15th bit of DR
&amp;nbsp;&amp;nbsp;&amp;nbsp; }
&amp;nbsp;&amp;nbsp;&amp;nbsp; return 0 ;
}
&lt;/PRE&gt; &lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 15 Jun 2016 20:00:53 GMT</pubDate>
    <dc:creator>lpcware</dc:creator>
    <dc:date>2016-06-15T20:00:53Z</dc:date>
    <item>
      <title>Problems with ADC conversion</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/Problems-with-ADC-conversion/m-p/559924#M15976</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by ledi007 on Tue Apr 19 07:02:19 MST 2016&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;Hello,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;i do my first steps with an LPC822 and would like to make a simple ADC conversion @ ADC_2 pin.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I wrote this code for initialization and basically the code works, but the result is wrong.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;On ADC_2 (pin PIO_14) i had connected a poti between Vcc and GND. As result i get only the value 0 and 4095.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Every 200ms i start an adc conversion in the SysTick_Handler and in the endless loop i read the adc data register of channel 2.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I hope, someone can help me ?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Here is my code:&lt;/SPAN&gt;&lt;BR /&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD bgcolor="#cacaca"&gt; &lt;PRE&gt;
#include "chip.h"
#include &amp;lt;cr_section_macros.h&amp;gt;

void SysTick_Handler(void)
{
LPC_GPIO_PORT-&amp;gt;NOT[0] = (1&amp;lt;&amp;lt;15);// Toggle PIO0_15
Chip_ADC_StartSequencer(LPC_ADC, ADC_SEQA_IDX);// manual start for ADC conversion sequence A
}

int main(void)
{
uint32_t rawSample, ADC_result;

Chip_SystemInit();// setup system clocking
SystemCoreClockUpdate();// Read clock settings and update SystemCoreClock variable
&amp;nbsp;&amp;nbsp;&amp;nbsp; SysTick_Config(SystemCoreClock / 5);// Systick is reloading 1/5 of a second = 200ms...

&amp;nbsp;&amp;nbsp;&amp;nbsp; LPC_GPIO_PORT-&amp;gt;DIR[0] |= (1&amp;lt;&amp;lt;15); // Set direction of PIO0_15 to output

&amp;nbsp;&amp;nbsp;&amp;nbsp; Chip_ADC_Init(LPC_ADC,0);// setup ADC 12-bit mode, normal power
&amp;nbsp;&amp;nbsp;&amp;nbsp; Chip_ADC_StartCalibration(LPC_ADC);// calibration after ADC initialization
&amp;nbsp;&amp;nbsp;&amp;nbsp; while (!(Chip_ADC_IsCalibrationDone(LPC_ADC))) {}

&amp;nbsp;&amp;nbsp;&amp;nbsp; Chip_ADC_SetClockRate(LPC_ADC, ADC_MAX_SAMPLE_RATE);
&amp;nbsp;&amp;nbsp;&amp;nbsp; Chip_ADC_SetupSequencer(LPC_ADC, ADC_SEQA_IDX, (ADC_SEQ_CTRL_CHANSEL(2) | ADC_SEQ_CTRL_MODE_EOS)); // setup SEQA, ADC_CH2
&amp;nbsp;&amp;nbsp;&amp;nbsp; Chip_Clock_EnablePeriphClock(SYSCTL_CLOCK_SWM); // enable the clock to the switch matrix
&amp;nbsp;&amp;nbsp;&amp;nbsp; Chip_SWM_EnableFixedPin(SWM_FIXED_ADC2);// config the switch matrix&amp;nbsp; for PIO0_14 as the input for ADC_2
&amp;nbsp;&amp;nbsp;&amp;nbsp; Chip_Clock_DisablePeriphClock(SYSCTL_CLOCK_SWM); // disable the clock to the switch matrix to save power
&amp;nbsp;&amp;nbsp;&amp;nbsp; Chip_ADC_EnableSequencer(LPC_ADC, ADC_SEQA_IDX);// enable sequencer

&amp;nbsp;&amp;nbsp;&amp;nbsp; while(1)
&amp;nbsp;&amp;nbsp;&amp;nbsp; {
&amp;nbsp;&amp;nbsp;&amp;nbsp; rawSample = Chip_ADC_GetDataReg(LPC_ADC, 2);// read ADC data register of ADC channel 2
&amp;nbsp;&amp;nbsp;&amp;nbsp; ADC_result = (rawSample &amp;gt;&amp;gt; 4) &amp;amp; 0xFFF;&amp;nbsp; // getting adc converted result from 4th to 15th bit of DR
&amp;nbsp;&amp;nbsp;&amp;nbsp; }
&amp;nbsp;&amp;nbsp;&amp;nbsp; return 0 ;
}
&lt;/PRE&gt; &lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Jun 2016 20:00:53 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/Problems-with-ADC-conversion/m-p/559924#M15976</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-15T20:00:53Z</dc:date>
    </item>
    <item>
      <title>Re: Problems with ADC conversion</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/Problems-with-ADC-conversion/m-p/559925#M15977</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by IanB on Wed Apr 20 00:40:30 MST 2016&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;Is the ADC bit enabled in PDRUNCFG and SYSAHBCLKCTRL?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Jun 2016 20:00:54 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/Problems-with-ADC-conversion/m-p/559925#M15977</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-15T20:00:54Z</dc:date>
    </item>
    <item>
      <title>Re: Problems with ADC conversion</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/Problems-with-ADC-conversion/m-p/559926#M15978</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by ledi007 on Wed Apr 20 03:13:14 MST 2016&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;Yes, it is enabled in PDRUNCFG and SYSAHBCLKCTRL&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Jun 2016 20:00:55 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/Problems-with-ADC-conversion/m-p/559926#M15978</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-15T20:00:55Z</dc:date>
    </item>
    <item>
      <title>Re: Problems with ADC conversion</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/Problems-with-ADC-conversion/m-p/559927#M15979</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by IanB on Thu Apr 21 03:11:11 MST 2016&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;Nothing too obvious - a little more investigation is required. . .&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Assuming a linear pot, does the voltage on the pin equal half-supply when the pot is in the middle? (That gives a clue if anything internally is driving the pin)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;At what voltage on the pin does the reading change from 0 to 4095?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Jun 2016 20:00:56 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/Problems-with-ADC-conversion/m-p/559927#M15979</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-15T20:00:56Z</dc:date>
    </item>
    <item>
      <title>Re: Problems with ADC conversion</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/Problems-with-ADC-conversion/m-p/559928#M15980</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by ledi007 on Thu Apr 21 05:20:30 MST 2016&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;now i measured the voltage @ ADC_2 pin with a resistance divider (Vcc---10k---10k---GND). I measured a voltage of 1,8V by Vcc = 3,2V. Thats not exactly the half! The reading change from 0 to 4095 or from 4095 to 0 at a voltage on the pin of 0,24V.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Attached you can see the content of the registers adc, sysahbclkctrl, iocon and adc after initialization.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Jun 2016 20:00:56 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/Problems-with-ADC-conversion/m-p/559928#M15980</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-15T20:00:56Z</dc:date>
    </item>
    <item>
      <title>Re: Problems with ADC conversion</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/Problems-with-ADC-conversion/m-p/559929#M15981</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by ledi007 on Thu Apr 21 05:52:10 MST 2016&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;oh my goodness :- i had solved the problem!&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;It was unfortunately self-made by myself...i forgot to connect the pins VREFN with GND and VREFP with Vcc.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Now it works!&amp;nbsp; :bigsmile: &lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Jun 2016 20:00:57 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/Problems-with-ADC-conversion/m-p/559929#M15981</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-15T20:00:57Z</dc:date>
    </item>
    <item>
      <title>Re: Problems with ADC conversion</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/Problems-with-ADC-conversion/m-p/559930#M15982</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by IanB on Thu Apr 21 07:40:39 MST 2016&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;I always wondered what would happen if you didn't connect them - they are always such a pain to track on the pcb.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Jun 2016 20:00:57 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/Problems-with-ADC-conversion/m-p/559930#M15982</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-15T20:00:57Z</dc:date>
    </item>
    <item>
      <title>Re: Problems with ADC conversion</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/Problems-with-ADC-conversion/m-p/559931#M15983</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;bump&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 19 Jun 2016 01:08:49 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/Problems-with-ADC-conversion/m-p/559931#M15983</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-19T01:08:49Z</dc:date>
    </item>
  </channel>
</rss>

