<?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のトピックRe: Debug vs release</title>
    <link>https://community.nxp.com/t5/LPC-Microcontrollers/Debug-vs-release/m-p/560759#M16154</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by Vaque on Thu Mar 17 04:13:15 MST 2016&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;that's fast!&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;It's running well on release build with 'volatile'. &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks so much to both of you.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Regards.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 15 Jun 2016 19:59:26 GMT</pubDate>
    <dc:creator>lpcware</dc:creator>
    <dc:date>2016-06-15T19:59:26Z</dc:date>
    <item>
      <title>Debug vs release</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/Debug-vs-release/m-p/560756#M16151</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by Vaque on Wed Mar 16 11:27:45 MST 2016&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;Hi all;&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I have this code running on lpc824 max board. The code runs well on debug build but not on release build. Why is it?. It seems that fail the timer.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks all.&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;

#include "board.h"
#include "chip.h"

#define GPIO_PINRXD0 //MAX: D0
#define GPIO_PINTXD19 //MAX: D2
#define UART_BAUDRATE&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 115200

bool flag_MRT0 = false;

bool setPowerState(int power_state){
uint32_t response;
uint32_t cmdData[3];

cmdData[0] = 12;
cmdData[1] = power_state;
cmdData[2] = 12;

Chip_Clock_SetMainClockSource(SYSCTL_MAINCLKSRC_IRC);
SystemCoreClockUpdate();
__disable_irq();
LPC_ROM_API-&amp;gt;pPWRD-&amp;gt;set_power(cmdData, &amp;amp;response);
__enable_irq();

if(response)
return false;
return true;
}

static void setupMRT(uint8_t ch, MRT_MODE_T mode, uint32_t rate)
{
LPC_MRT_CH_T *pMRT;


/* Get pointer to timer selected by ch */
pMRT = Chip_MRT_GetRegPtr(ch);

/* Setup timer with rate based on MRT clock */

Chip_MRT_SetInterval(pMRT, (Chip_Clock_GetSystemClockRate() / rate) |
 MRT_INTVAL_LOAD);

/* Timer mode */
Chip_MRT_SetMode(pMRT, mode);

/* Clear pending interrupt and enable timer */
Chip_MRT_IntClear(pMRT);
Chip_MRT_SetEnabled(pMRT);
}

/**
 * @briefHandle interrupt from MRT
 * @returnNothing
 */
void MRT_IRQHandler(void)
{
uint32_t int_pend;

/* Get interrupt pending status for all timers&amp;nbsp; and clear it*/
int_pend = Chip_MRT_GetIntPending();
Chip_MRT_ClearIntPending(int_pend);
/* MRT 0 */
if (int_pend &amp;amp; (MRTn_INTFLAG(0))) {
flag_MRT0 = true;
}
}

static void blinkLEDCount(uint32_t count)
{
volatile uint32_t index;

/* Perform the requested number of times */
for (; count; --count) {
Board_LED_Toggle(0);
for (index = 0; index &amp;lt; 100000; ++index) {}/* delay */
Board_LED_Toggle(0);
for (index = 0; index &amp;lt; 100000; ++index) {}/* delay */
}
}

void UART_config_Init(){
/* Enable the clock to the Switch Matrix */
Chip_Clock_EnablePeriphClock(SYSCTL_CLOCK_SWM);

// Change pin to UARTn function
Chip_SWM_MovablePinAssign(SWM_U0_TXD_O, GPIO_PINTXD);
Chip_SWM_MovablePinAssign(SWM_U0_RXD_I, GPIO_PINRXD);

/* Disable the clock to the Switch Matrix */
Chip_Clock_DisablePeriphClock(SYSCTL_CLOCK_SWM);

/* Setup UARTn */
Chip_UART_Init(LPC_USART0);
Chip_UART_ConfigData(LPC_USART0, UART_CFG_DATALEN_8 | UART_CFG_PARITY_NONE | UART_CFG_STOPLEN_1);
Chip_Clock_SetUSARTNBaseClockRate((UART_BAUDRATE * 16), true);
Chip_UART_SetBaud(LPC_USART0, UART_BAUDRATE);
Chip_UART_Enable(LPC_USART0);
Chip_UART_TXEnable(LPC_USART0);
}

int main(void)
{
int mrtch;

/* Generic Initialization */
SystemCoreClockUpdate();
Board_Init();

/* Set power state */
/* if failure response don't proceed */
if (!setPowerState(PWR_CPU_PERFORMANCE)) {
while (1) {
blinkLEDCount(2);
}
}

/* Config and Init UART0 */
UART_config_Init();

Chip_MRT_Init();
for (mrtch = 0; mrtch &amp;lt; MRT_CHANNELS_NUM; mrtch++) {
Chip_MRT_SetDisabled(Chip_MRT_GetRegPtr(mrtch));
}
/* Enable the interrupt for the MRT */
NVIC_EnableIRQ(MRT_IRQn);

flag_MRT0 = false;
setupMRT(0, MRT_MODE_ONESHOT, 500);
while(!flag_MRT0) __WFI();
Chip_UART_SendBlocking(LPC_USART0, "go\r\n", 4);
while ( 1 ) {

}
}
&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 19:59:23 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/Debug-vs-release/m-p/560756#M16151</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-15T19:59:23Z</dc:date>
    </item>
    <item>
      <title>Re: Debug vs release</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/Debug-vs-release/m-p/560757#M16152</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by starblue on Wed Mar 16 16:05:38 MST 2016&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;Try declaring flag_MRT0 as volatile.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Jun 2016 19:59:24 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/Debug-vs-release/m-p/560757#M16152</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-15T19:59:24Z</dc:date>
    </item>
    <item>
      <title>Re: Debug vs release</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/Debug-vs-release/m-p/560758#M16153</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by R2D2 on Wed Mar 16 23:10:37 MST 2016&lt;/STRONG&gt;&lt;BR /&gt;&lt;HR /&gt;&lt;SPAN style="color: #0000ff;"&gt;&lt;STRONG&gt;Quote: Vaque&lt;/STRONG&gt;&lt;BR /&gt;Why is it?&lt;/SPAN&gt;&lt;HR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;FAQ: 'Optimized code fails to execute correctly'&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;&lt;A class="jive-link-external-small" href="https://community.nxp.com/external-link.jspa?url=https%3A%2F%2Fwww.lpcware.com%2Fcontent%2Ffaq%2Flpcxpresso%2Fcompiler-optimization" rel="nofollow" target="_blank"&gt;https://www.lpcware.com/content/faq/lpcxpresso/compiler-optimization&lt;/A&gt;&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Jun 2016 19:59:25 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/Debug-vs-release/m-p/560758#M16153</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-15T19:59:25Z</dc:date>
    </item>
    <item>
      <title>Re: Debug vs release</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/Debug-vs-release/m-p/560759#M16154</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by Vaque on Thu Mar 17 04:13:15 MST 2016&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;that's fast!&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;It's running well on release build with 'volatile'. &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks so much to both of you.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Regards.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Jun 2016 19:59:26 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/Debug-vs-release/m-p/560759#M16154</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-15T19:59:26Z</dc:date>
    </item>
    <item>
      <title>Re: Debug vs release</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/Debug-vs-release/m-p/560760#M16155</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:05:22 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/Debug-vs-release/m-p/560760#M16155</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-19T01:05:22Z</dc:date>
    </item>
  </channel>
</rss>

