<?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>LPCXpresso IDEのトピックRe: ADC Register Reading Problem</title>
    <link>https://community.nxp.com/t5/LPCXpresso-IDE/ADC-Register-Reading-Problem/m-p/555259#M13596</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by CodeRedSupport on Wed Mar 09 03:11:48 MST 2011&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;What level of optimisation is your code built at?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I suspect that this is a "debug illusion" issue caused by your code being built, say, at -Os (the default for a release build). Effectively at the point your breakpoint is set, your locals are "no longer required" within your code, and the debug table entries are no longer valid, and you are effectively seeing garbage in the variables view.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;For more information on the effects of optimisation on debugging see the FAQ at:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;A href="http://"&gt;http://support.code-red-tech.com/CodeRedWiki/CompilerOptimization&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;To workaround this, you could either change the optimisation level on just the file containing ADC_IRQHandler(), as per:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;[FONT=monospace]&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&lt;SPAN&gt;[/FONT]&lt;/SPAN&gt;&lt;A class="jive-link-external-small" href="https://community.nxp.com/external-link.jspa?url=http%3A%2F%2Fsupport.code-red-tech.com%2FCodeRedWiki%2FPerFileProperties" rel="nofollow" target="_blank"&gt;http://support.code-red-tech.com/CodeRedWiki/PerFileProperties&lt;/A&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;or you could perhaps make value1/2/3 globals temporarily whilst you are debugging the code.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Regards,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;CodeRedSupport&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 16 Jun 2016 02:04:25 GMT</pubDate>
    <dc:creator>lpcware</dc:creator>
    <dc:date>2016-06-16T02:04:25Z</dc:date>
    <item>
      <title>ADC Register Reading Problem</title>
      <link>https://community.nxp.com/t5/LPCXpresso-IDE/ADC-Register-Reading-Problem/m-p/555258#M13595</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by danmec on Mon Mar 07 13:37:09 MST 2011&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;I am trying out the LPC1114 LPCXpresso board and I am having some issues with the ADC.&amp;nbsp; I currently have a program running that starts an adc conversion on one of AD0-AD3 initiated by the timer.&amp;nbsp; I set a break point inside the adc irq handler after I transfer LPC_ADC-&amp;gt;DR[selectedChannel] to a variable named value1.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;The issue I am having is that value1 is not getting the correct value every time, just most of the time.&amp;nbsp; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;This is based on the debugger showing ADDR0 and value1 as different.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I tied AD0 to 3.3V and I get the expected value from the debugger window.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Below is the ADC related code and attached is the debugger view stopped at the "selectedChannel++;" line&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 initAdc() {

/* Disable Power down bit to the ADC block. */
LPC_SYSCON-&amp;gt;PDRUNCFG &amp;amp;= ~(0x1 &amp;lt;&amp;lt; 4);

/* Enable AHB clock to the ADC. */
LPC_SYSCON-&amp;gt;SYSAHBCLKCTRL |= (1 &amp;lt;&amp;lt; 13);

LPC_IOCON-&amp;gt;R_PIO0_11 = 0x02; // Select AD0 pin function
LPC_IOCON-&amp;gt;R_PIO1_0 = 0x02; // Select AD0 pin function
LPC_IOCON-&amp;gt;R_PIO1_1 = 0x02; // Select AD0 pin function
LPC_IOCON-&amp;gt;R_PIO1_2 = 0x02; // Select AD0 pin function

LPC_ADC-&amp;gt;CR = ((SystemCoreClock / LPC_SYSCON-&amp;gt;SYSAHBCLKDIV) / 2400000 - 1) &amp;lt;&amp;lt; 8; // Set clock to 2.4 MHz

LPC_ADC-&amp;gt;CR |= 0x01; // Select channel AD0


NVIC_EnableIRQ(ADC_IRQn);
LPC_ADC-&amp;gt;INTEN = 0x00F;// enable ADC0 interrupt
}

void ADC_IRQHandler (void)
{
static volatile uint8_t selectedChannel = 0;
volatile uint32_t value1 = 0, value2 = 0, value3 = 0;
value1 = LPC_ADC-&amp;gt;DR[selectedChannel]; //this line doesn't seem to transfer the result correctly all the time
value2 = value1 &amp;gt;&amp;gt; 6;
value3 = value2 &amp;amp; 0x3FF;

selectedChannel++;
if(selectedChannel &amp;gt; 3){
selectedChannel = 0;
}

LPC_ADC-&amp;gt;CR &amp;amp;= ~0x00FF;
LPC_ADC-&amp;gt;CR |= (1&amp;lt;&amp;lt;selectedChannel);
}
&lt;/PRE&gt; &lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 16 Jun 2016 02:04:24 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPCXpresso-IDE/ADC-Register-Reading-Problem/m-p/555258#M13595</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-16T02:04:24Z</dc:date>
    </item>
    <item>
      <title>Re: ADC Register Reading Problem</title>
      <link>https://community.nxp.com/t5/LPCXpresso-IDE/ADC-Register-Reading-Problem/m-p/555259#M13596</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by CodeRedSupport on Wed Mar 09 03:11:48 MST 2011&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;What level of optimisation is your code built at?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I suspect that this is a "debug illusion" issue caused by your code being built, say, at -Os (the default for a release build). Effectively at the point your breakpoint is set, your locals are "no longer required" within your code, and the debug table entries are no longer valid, and you are effectively seeing garbage in the variables view.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;For more information on the effects of optimisation on debugging see the FAQ at:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;A href="http://"&gt;http://support.code-red-tech.com/CodeRedWiki/CompilerOptimization&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;To workaround this, you could either change the optimisation level on just the file containing ADC_IRQHandler(), as per:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;[FONT=monospace]&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&lt;SPAN&gt;[/FONT]&lt;/SPAN&gt;&lt;A class="jive-link-external-small" href="https://community.nxp.com/external-link.jspa?url=http%3A%2F%2Fsupport.code-red-tech.com%2FCodeRedWiki%2FPerFileProperties" rel="nofollow" target="_blank"&gt;http://support.code-red-tech.com/CodeRedWiki/PerFileProperties&lt;/A&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;or you could perhaps make value1/2/3 globals temporarily whilst you are debugging the code.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Regards,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;CodeRedSupport&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 16 Jun 2016 02:04:25 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPCXpresso-IDE/ADC-Register-Reading-Problem/m-p/555259#M13596</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-16T02:04:25Z</dc:date>
    </item>
  </channel>
</rss>

