<?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: Why are external SDRAM initializations so different on LPCOpen vs. mbed?</title>
    <link>https://community.nxp.com/t5/LPC-Microcontrollers/Why-are-external-SDRAM-initializations-so-different-on-LPCOpen/m-p/734287#M29662</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Brendon,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;you're right, if you use the GCC setup, then the startup files are realized in C code in the framework.&lt;/P&gt;&lt;P&gt;IAR and Keil tools normally use an assembler file, just another thing which is just a philosophy. Technically both options are there, one tool simply uses it this way, the other one the other way.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The entry point is always the reset handler. If you able to localize it, then you have the piece of code which gets located at the address the linker puts it to.&lt;/P&gt;&lt;P&gt;The beginning of an image for the ARM Cortex-M is always the same:&lt;/P&gt;&lt;P&gt;- 4 bytes for address vector to stack pointer start&lt;/P&gt;&lt;P&gt;- 4 bytes for address vector to reset handler start&lt;/P&gt;&lt;P&gt;- 14 words with ARM exception vector addresses&lt;/P&gt;&lt;P&gt;- platform dependent number of IRQ vector addresses&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So when you look into the final binary, the second word tells you where the linker placed the reset handler. Normally the linker gets all the freedom to place it wherever it wants to, except if you hard-code it.&lt;/P&gt;&lt;P&gt;Anyway, in the GCC world the startup file is normally called cr_startup_xxxx.c, in there you might find "ResetISR" and that's the reset handler (in principle just another naming convention, could be different).&lt;/P&gt;&lt;P&gt;The way it is set up there, decides how it could work with the SDRAM.&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;If you want to relocate the whole code to the SDRAM before you start with execution, you need to initialize the SDRAM at first.&lt;/LI&gt;&lt;LI&gt;If you work on the basic init and the board bring up from internal SRAM or from Flash, then you can do the SDRAM init later and you relocate then all other objects to SDRAM starting with the object where main() is located.&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Maybe this helps a little bit.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Bernhard.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 13 Nov 2017 18:16:05 GMT</pubDate>
    <dc:creator>bernhardfink</dc:creator>
    <dc:date>2017-11-13T18:16:05Z</dc:date>
    <item>
      <title>Why are external SDRAM initializations so different on LPCOpen vs. mbed?</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/Why-are-external-SDRAM-initializations-so-different-on-LPCOpen/m-p/734282#M29657</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;SPAN style="color: #51626f; background-color: #ffffff;"&gt;&lt;STRONG&gt;I'm confused by the difference between initialization routines for an&amp;nbsp;external SDRAM in mbed (EALib) vs. LPCOpen examples. &lt;/STRONG&gt;I'm using&amp;nbsp;the&amp;nbsp;&lt;SPAN&gt;&lt;A href="https://community.nxp.com/external-link.jspa?url=https%3A%2F%2Fwww.embeddedartists.com%2Fproducts%2Fboards%2Flpc4088_qsb.php"&gt;Embedded Artists LPC4088 QuickStart Board&lt;/A&gt;&lt;/SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="color: #51626f; background-color: #ffffff;"&gt;in MCUXpresso IDE v10.0.2 [Build 411] [2017-07-11]. The board has an external 32 MB SDRAM chip.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #51626f; background-color: #ffffff;"&gt;One the one hand, you have the &lt;A href="https://os.mbed.com/users/embeddedartists/code/EALib/"&gt;mbed-based EALib&lt;/A&gt;, in which you're ostensibly supposed to call&amp;nbsp;&lt;SPAN style="font-family: 'courier new', courier, monospace;"&gt;sdram_init()&lt;/SPAN&gt; before using the external SDRAM. (See &lt;A href="https://os.mbed.com/users/embeddedartists/code/EALib/file/e1e36493f347/sdram.cpp"&gt;sdram.cpp&lt;/A&gt;.)&amp;nbsp;sdram_init() appears to be setting values in quite a few control registers.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #51626f; background-color: #ffffff;"&gt;On the other hand, you have the example &lt;A href="https://www.nxp.com/products/microcontrollers-and-processors/arm-based-processors-and-mcus/lpc-cortex-m-mcus/lpc-developer-resources-/lpcopen-libraries-and-examples/lpcopen-software-development-platform-lpc40xx:LPCOPEN-SOFTWARE-FOR-LPC40XX"&gt;LPCOpen Software for LPC40xx&lt;/A&gt;&amp;nbsp;(&lt;A href="https://www.nxp.com/downloads/en/libraries/lpcopen_2_10_lpcxpresso_ea_devkit_4088.zip"&gt;direct download link&lt;/A&gt;), which runs on the same board, but does almost none of that. Looking at the periph_memtest example in there, we see that only&amp;nbsp;&lt;SPAN style="font-family: 'courier new', courier, monospace;"&gt;SystemCoreClockUpdate()&lt;/SPAN&gt; and&amp;nbsp;&lt;SPAN style="font-family: 'courier new', courier, monospace;"&gt;Board_Init()&lt;/SPAN&gt; are called before accessing the memory. The only commonality between these and EALib's &lt;SPAN style="font-family: 'courier new', courier, monospace;"&gt;sdram_init()&lt;/SPAN&gt; is that there is one control register whose value they both&amp;nbsp;modify (&lt;SPAN style="font-family: 'courier new', courier, monospace;"&gt;LPC_SYSCTL-&amp;gt;PCONP&lt;/SPAN&gt;).&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="background-color: #ffffff; color: #51626f;"&gt;Why the discrepancy? How is LPCOpen getting by doing so little? Or why is EALib/mbed doing so much unnecessary stuff?&lt;/STRONG&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 30 Oct 2017 16:51:56 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/Why-are-external-SDRAM-initializations-so-different-on-LPCOpen/m-p/734282#M29657</guid>
      <dc:creator>bmcdonnell_ionx</dc:creator>
      <dc:date>2017-10-30T16:51:56Z</dc:date>
    </item>
    <item>
      <title>Re: Why are external SDRAM initializations so different on LPCOpen vs. mbed?</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/Why-are-external-SDRAM-initializations-so-different-on-LPCOpen/m-p/734283#M29658</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi &lt;A _jive_internal="true" data-content-finding="Community" data-userid="306394" data-username="bmcdonnell_ionx" href="https://community.nxp.com/people/bmcdonnell_ionx" rel="nofollow noopener noreferrer" target="_blank"&gt;Brendan McDonnell&lt;/A&gt;,&lt;/P&gt;&lt;DIV style="white-space: pre-wrap; text-align: left; line-height: 1.75; font-size: 14px;"&gt;&lt;SPAN style="font-family: 'Microsoft YaHei', STXihei; background-color: #ffffff;"&gt;Thank you for your interest in NXP Semiconductor products and&amp;nbsp;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV style="white-space: pre-wrap; text-align: left; line-height: 1.75; font-size: 14px;"&gt;&lt;SPAN style="font-family: 'Microsoft YaHei', STXihei; background-color: #ffffff;"&gt;for the opportunity to serve you.&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV style="white-space: pre-wrap; text-align: left; line-height: 1.75; font-size: 14px;"&gt;&lt;SPAN style="font-family: 'Microsoft YaHei', STXihei; background-color: #ffffff;"&gt;In LPCOpen library, SDRAM is initialized before the jump to main();&lt;/SPAN&gt;&lt;/DIV&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="language-c line-numbers"&gt;&lt;CODE&gt;&lt;SPAN class="keyword token"&gt;void&lt;/SPAN&gt; &lt;SPAN class="token function"&gt;Board_SetupExtMemory&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="keyword token"&gt;void&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
&lt;SPAN class="punctuation token"&gt;{&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN class="comment token"&gt;/* Setup EMC Delays */&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN class="comment token"&gt;/* Move all clock delays together */&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; LPC_SYSCTL&lt;SPAN class="operator token"&gt;-&amp;gt;&lt;/SPAN&gt;EMCDLYCTL &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;CLK0_DELAY&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt; &lt;SPAN class="operator token"&gt;|&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;CLK0_DELAY &lt;SPAN class="operator token"&gt;&amp;lt;&amp;lt;&lt;/SPAN&gt; &lt;SPAN class="number token"&gt;8&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt; &lt;SPAN class="operator token"&gt;|&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;CLK0_DELAY &lt;SPAN class="operator token"&gt;&amp;lt;&amp;lt;&lt;/SPAN&gt; &lt;SPAN class="number token"&gt;16&lt;/SPAN&gt; &lt;SPAN class="operator token"&gt;|&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;CLK0_DELAY &lt;SPAN class="operator token"&gt;&amp;lt;&amp;lt;&lt;/SPAN&gt; &lt;SPAN class="number token"&gt;24&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;

&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN class="comment token"&gt;/* Setup EMC Clock Divider for divide by 2 */&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN class="comment token"&gt;/* Setup EMC clock for a divider of 2 from CPU clock. Enable EMC clock for
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; external memory setup of DRAM. */&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN class="token function"&gt;Chip_Clock_SetEMCClockDiv&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;SYSCTL_EMC_DIV2&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN class="token function"&gt;Chip_SYSCTL_PeriphReset&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;SYSCTL_RESET_EMC&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;

&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN class="comment token"&gt;/* Init EMC Controller -Enable-LE mode- clock ratio 1:1 */&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN class="token function"&gt;Chip_EMC_Init&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;1&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="number token"&gt;0&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="number token"&gt;0&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;

&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN class="comment token"&gt;/* Init EMC Dynamic Controller */&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN class="token function"&gt;Chip_EMC_Dynamic_Init&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;IP_EMC_DYN_CONFIG_T &lt;SPAN class="operator token"&gt;*&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt; &lt;SPAN class="operator token"&gt;&amp;amp;&lt;/SPAN&gt;IS42S32800D_config&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;

&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN class="comment token"&gt;/* Init EMC Static Controller CS0 */&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN class="token function"&gt;Chip_EMC_Static_Init&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;IP_EMC_STATIC_CONFIG_T &lt;SPAN class="operator token"&gt;*&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt; &lt;SPAN class="operator token"&gt;&amp;amp;&lt;/SPAN&gt;SST39VF320_config&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;

&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN class="comment token"&gt;/* Init EMC Static Controller CS1 */&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN class="token function"&gt;Chip_EMC_Static_Init&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;IP_EMC_STATIC_CONFIG_T &lt;SPAN class="operator token"&gt;*&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt; &lt;SPAN class="operator token"&gt;&amp;amp;&lt;/SPAN&gt;K9F1G_config&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;

&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN class="comment token"&gt;/* EMC Shift Control */&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; LPC_SYSCTL&lt;SPAN class="operator token"&gt;-&amp;gt;&lt;/SPAN&gt;SCS &lt;SPAN class="operator token"&gt;|&lt;/SPAN&gt;&lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="number token"&gt;1&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;
&lt;SPAN class="punctuation token"&gt;}&lt;/SPAN&gt;

&lt;SPAN class="comment token"&gt;/* Set up and initialize hardware prior to call to main */&lt;/SPAN&gt;
&lt;SPAN class="keyword token"&gt;void&lt;/SPAN&gt; &lt;SPAN class="token function"&gt;Board_SystemInit&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="keyword token"&gt;void&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
&lt;SPAN class="punctuation token"&gt;{&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN class="token function"&gt;Board_SetupMuxing&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN class="token function"&gt;Board_SetupClocking&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN class="token function"&gt;Board_SetupExtMemory&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;
&lt;SPAN class="punctuation token"&gt;}&lt;/SPAN&gt;&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;DIV&gt;&lt;P style="color: #51626f; border: 0px;"&gt;Hope this is clear.&lt;/P&gt;&lt;P style="color: #51626f; border: 0px;"&gt;Have a great day,&lt;BR /&gt;TIC&lt;/P&gt;&lt;P style="color: #51626f; border: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P style="color: #51626f; border: 0px;"&gt;-----------------------------------------------------------------------------------------------------------------------&lt;BR /&gt;Note: If this post answers your question, please click the Correct Answer button. Thank you!&lt;BR /&gt;-----------------------------------------------------------------------------------------------------------------------&lt;/P&gt;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 02 Nov 2017 02:25:48 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/Why-are-external-SDRAM-initializations-so-different-on-LPCOpen/m-p/734283#M29658</guid>
      <dc:creator>jeremyzhou</dc:creator>
      <dc:date>2017-11-02T02:25:48Z</dc:date>
    </item>
    <item>
      <title>Re: Why are external SDRAM initializations so different on LPCOpen vs. mbed?</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/Why-are-external-SDRAM-initializations-so-different-on-LPCOpen/m-p/734284#M29659</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive_macro_quote jive-quote jive_text_macro"&gt;&lt;P&gt;jeremyzhou wrote:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: #ffffff;"&gt;In LPCOpen library, SDRAM is initialized before the jump to main();&lt;/SPAN&gt;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;What is the entry point, and how/where is that defined?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks for the info.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 02 Nov 2017 13:11:09 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/Why-are-external-SDRAM-initializations-so-different-on-LPCOpen/m-p/734284#M29659</guid>
      <dc:creator>bmcdonnell_ionx</dc:creator>
      <dc:date>2017-11-02T13:11:09Z</dc:date>
    </item>
    <item>
      <title>Re: Why are external SDRAM initializations so different on LPCOpen vs. mbed?</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/Why-are-external-SDRAM-initializations-so-different-on-LPCOpen/m-p/734285#M29660</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Brendan,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;wherever in the code the SDRAM is initialized, the instructions are finally the same. But there are of course different ways to program the instructions. Simple sequential write instructions to all required registers, working with structs and loops, etc. But to make the SDRAM working, you need to have them all written correctly and in the right order.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The position in the code where this initialization is done is also debatable. You only need to take care that it is done before you access it. You could think of 2 extreme scenarios:&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;You just want to use the SDRAM for a display frame buffer. All executable code and variables are in flash and RAM. You don't provide the SDRAM&amp;nbsp;memory area as available memory to the linker. So latest when you set up your display you need to prepare the SDRAM.&lt;BR /&gt;&lt;BR /&gt;&lt;/LI&gt;&lt;LI&gt;You want to place code and variables into the SDRAM and you want the linker to do this. Therefore you need to prepare the SDRAM in a very early stage, you can even do this in startup.s. The linker can place all C objects into the SDRAM, only the startup.s is executed from the boot memory, e.g. the internal flash. All other objects will be copied from the non-volatile memory to the SDRAM and then executed from there.&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In LPCOpen we selected something between 1) and 2). The startup.s and the sys_init stuff (sysinit and board_sysinit) runs from the boot memory and prepares all the rest, for example also the SDRAM. At the end of the sys_init stuff the compiler may place code for relocation of objects which were specified in the linker file (scatter file) to be somewhere else, for example in the SDRAM.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Another meaningful example is the placement of code into the SDRAM with a debugger. Here it it is very clear that you need to set up the PLLs and the SDRAM memory interface with an ini script before the debugger can write the code image to the SDRAM.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Whenever and wherever you perform the SDRAM initialization, you only need to be done with it before it's getting accessed.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Bernhard.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 02 Nov 2017 15:22:37 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/Why-are-external-SDRAM-initializations-so-different-on-LPCOpen/m-p/734285#M29660</guid>
      <dc:creator>bernhardfink</dc:creator>
      <dc:date>2017-11-02T15:22:37Z</dc:date>
    </item>
    <item>
      <title>Re: Why are external SDRAM initializations so different on LPCOpen vs. mbed?</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/Why-are-external-SDRAM-initializations-so-different-on-LPCOpen/m-p/734286#M29661</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Bernhard,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Apologies for&amp;nbsp;my delay in responding. Priorities shift...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks for the info. I'm still not quite clear on the answers to my questions, though.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I asked,&lt;/P&gt;&lt;BLOCKQUOTE class="jive_macro_quote jive-quote jive_text_macro"&gt;&lt;P style="color: #51626f; background-color: #ffffff; border: 0px; margin: 0px; padding: 0px;"&gt;What is the entry point, and how/where is that defined?&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;You said, in part,&lt;/P&gt;&lt;BLOCKQUOTE class="jive_macro_quote jive-quote jive_text_macro"&gt;&lt;P&gt;Bernhard Fink wrote:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #51626f; background-color: #ffffff;"&gt;In LPCOpen ... The startup.s and the sys_init stuff (sysinit and board_sysinit) runs from the boot memory and prepares all the rest, for example also the SDRAM.&lt;/SPAN&gt;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;When the microcontroller boots, what runs first, and how is it configured to be the first thing to run? For instance, is SystemInit() the first thing to run? What if I wanted something else to execute before the first thing - how would I change that?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Also, startup.s&amp;nbsp;is not in this sample code.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 13 Nov 2017 16:55:31 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/Why-are-external-SDRAM-initializations-so-different-on-LPCOpen/m-p/734286#M29661</guid>
      <dc:creator>bmcdonnell_ionx</dc:creator>
      <dc:date>2017-11-13T16:55:31Z</dc:date>
    </item>
    <item>
      <title>Re: Why are external SDRAM initializations so different on LPCOpen vs. mbed?</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/Why-are-external-SDRAM-initializations-so-different-on-LPCOpen/m-p/734287#M29662</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Brendon,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;you're right, if you use the GCC setup, then the startup files are realized in C code in the framework.&lt;/P&gt;&lt;P&gt;IAR and Keil tools normally use an assembler file, just another thing which is just a philosophy. Technically both options are there, one tool simply uses it this way, the other one the other way.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The entry point is always the reset handler. If you able to localize it, then you have the piece of code which gets located at the address the linker puts it to.&lt;/P&gt;&lt;P&gt;The beginning of an image for the ARM Cortex-M is always the same:&lt;/P&gt;&lt;P&gt;- 4 bytes for address vector to stack pointer start&lt;/P&gt;&lt;P&gt;- 4 bytes for address vector to reset handler start&lt;/P&gt;&lt;P&gt;- 14 words with ARM exception vector addresses&lt;/P&gt;&lt;P&gt;- platform dependent number of IRQ vector addresses&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So when you look into the final binary, the second word tells you where the linker placed the reset handler. Normally the linker gets all the freedom to place it wherever it wants to, except if you hard-code it.&lt;/P&gt;&lt;P&gt;Anyway, in the GCC world the startup file is normally called cr_startup_xxxx.c, in there you might find "ResetISR" and that's the reset handler (in principle just another naming convention, could be different).&lt;/P&gt;&lt;P&gt;The way it is set up there, decides how it could work with the SDRAM.&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;If you want to relocate the whole code to the SDRAM before you start with execution, you need to initialize the SDRAM at first.&lt;/LI&gt;&lt;LI&gt;If you work on the basic init and the board bring up from internal SRAM or from Flash, then you can do the SDRAM init later and you relocate then all other objects to SDRAM starting with the object where main() is located.&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Maybe this helps a little bit.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Bernhard.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 13 Nov 2017 18:16:05 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/Why-are-external-SDRAM-initializations-so-different-on-LPCOpen/m-p/734287#M29662</guid>
      <dc:creator>bernhardfink</dc:creator>
      <dc:date>2017-11-13T18:16:05Z</dc:date>
    </item>
    <item>
      <title>Re: Why are external SDRAM initializations so different on LPCOpen vs. mbed?</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/Why-are-external-SDRAM-initializations-so-different-on-LPCOpen/m-p/734288#M29663</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Very informative, thanks. Now I can put together the answer to my original question (which I didn't know how to ask).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I asked how the LPCOpen code was getting by without initializing the external SDRAM. But it only seemed to me like that because main() is not the entry point in this case, and the memory is initialized before main().&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You described in your latest comment the location in memory that specifies the location of&amp;nbsp;the reset handler function. (The reset handler function is what I would say is the "entry point" at the lowest level (or close to it).) In this case, the entry point is the ResetISR() function, located in cr_startup_lpc40xx.c.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So the portion of the call tree leading to the memory initialization (before main()) is as shown below (where each function calls the next).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;TABLE class="j-table jiveBorder" style="border: 1px solid #c6c6c6; width: 54.386%;"&gt;&lt;THEAD&gt;&lt;TR style="background-color: #efefef; height: 25px;"&gt;&lt;TH style="width: 10%; height: 25px;"&gt;Function&lt;/TH&gt;&lt;TH style="width: 10%; height: 25px;"&gt;source file&lt;/TH&gt;&lt;/TR&gt;&lt;/THEAD&gt;&lt;TBODY&gt;&lt;TR style="height: 25px;"&gt;&lt;TD style="width: 10%; height: 25px;"&gt;ResetISR()&lt;/TD&gt;&lt;TD style="width: 10%; height: 25px;"&gt;cr_startup_lpc40xx.c&lt;/TD&gt;&lt;/TR&gt;&lt;TR style="height: 25px;"&gt;&lt;TD style="width: 10%; height: 25px;"&gt;SystemInit()&lt;/TD&gt;&lt;TD style="width: 10%; height: 25px;"&gt;sysinit.c&lt;/TD&gt;&lt;/TR&gt;&lt;TR style="height: 25px;"&gt;&lt;TD style="width: 10%; height: 25px;"&gt;Board_SystemInit()&lt;/TD&gt;&lt;TD style="width: 10%; height: 25px;"&gt;board_sysinit.c&lt;/TD&gt;&lt;/TR&gt;&lt;TR style="height: 25px;"&gt;&lt;TD style="width: 10%; height: 25px;"&gt;Board_SetupExtMemory()&lt;/TD&gt;&lt;TD style="width: 10%; height: 25px;"&gt;&lt;SPAN&gt;board_sysinit.c&lt;/SPAN&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;[EDIT: At risk of poor form, I'm marking this (my own) comment as "correct", but your comments as "helpful", since they all helped me put it together.]&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 13 Nov 2017 18:49:08 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/Why-are-external-SDRAM-initializations-so-different-on-LPCOpen/m-p/734288#M29663</guid>
      <dc:creator>bmcdonnell_ionx</dc:creator>
      <dc:date>2017-11-13T18:49:08Z</dc:date>
    </item>
  </channel>
</rss>

