<?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 FAQs中的主题 ROM Divide</title>
    <link>https://community.nxp.com/t5/LPCXpresso-IDE-FAQs/ROM-Divide/m-p/473825#M109</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;H1&gt;Background&lt;/H1&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Unlike the Cortex-M3 and M4, the Cortex-M0 does not provide support for divides in hardware. This means that when application code carries out a divide operation, the compiler will insert a call to a library divide function. Thus if your application, or the library routines it invokes, use divide operations, then a certain amount of space in your FLASH will be consumed by one or more library divide functions.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;[The divide function calls generated by the compiler are documented in the run-time section of the &lt;A _jive_internal="true" href="https://community.nxp.com/external-link.jspa?url=http%3A%2F%2Finfocenter.arm.com%2Fhelp%2Findex.jsp%3Ftopic%3D%2Fcom.arm.doc.subset.swdev.abi%2Findex.html"&gt;Application Binary Interface for the ARM Architecture&lt;/A&gt; (commonly known as the AEABI).]&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Certain NXP Cortex-M0 based MCU’s, such as &lt;STRONG&gt;LPC11Axx, LPC11Exx, LPC11Uxx and LPC12xx&lt;/STRONG&gt;, include optimized code in ROM to carry out divide operations. These ROM divide functions operate in "near-constant-time", such that a particular divide function will provide a result in approximately the same amount of cycles, regardless of inputs and the resulting value.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This contrasts with the standard divide library routines that will be pulled from the C library, where the performance will be based on the number of bits in the quotient (the result). For a given set of tests, the ROM divide routine performance is likely to be slower than the fastest performance possible from the standard divide library routines, but quicker than the slowest performance possible from the standard divide library routines.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The other advantage to using the ROM divide library routines is that if your application carries out divide operations, the code overhead of the divide function is removed from your flash (as the routines exist in the library ROM instead).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;H1&gt;Enabling the use of ROM Divide in LPCXpresso IDE&lt;/H1&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In order to make the ROM divide routines as easy to access from application code as possible, LPCXpresso IDE contains support within the project wizards for appropriate MCUs to redirect calls generated by the compiler to the AEABI divide routines directly on to the ROM divide routines.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;To enable this support, ensure that the &lt;STRONG&gt;&lt;TT&gt;"&lt;SPAN style="font-family: courier new,courier;"&gt;Enable use of RomDivide library by compiled code&lt;/SPAN&gt;"&lt;/TT&gt;&lt;/STRONG&gt; option is ticked in in the project wizard options...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/121299i58F6DD7073909F67/image-size/large?v=v2&amp;amp;px=999" title="146820_146820.jpg" alt="146820_146820.jpg" /&gt;&lt;/span&gt;&lt;span class="lia-inline-image-display-wrapper"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/36366iDC5DE60DC7696AEF/image-size/large?v=v2&amp;amp;px=999" title="lpcxpresso_romdivide.jpg" alt="lpcxpresso_romdivide.jpg" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The project wizard will then cause the appropriate compiler, assembler and linker options to be set for your project.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Note&lt;/STRONG&gt; that these project wizard will always create a file called &lt;TT&gt;"&lt;SPAN style="font-family: courier new,courier;"&gt;aeabi_romdiv_patch.s&lt;/SPAN&gt;"&lt;/TT&gt; into the &lt;TT&gt;src&lt;/TT&gt; directory of your new project, which contains the code to redirect the divide function calls onto the ROM divide routines. This will only take effect if the appropriate compiler, assembler and linker options are set.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you decide that you want to switch a project over to using the ROM divide routines when it was created without the support enabled, then you can do so as follows:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;&lt;P&gt;Select the project in the Project Explorer view and then open the Project properties.&lt;/P&gt;&lt;/LI&gt;&lt;LI&gt;&lt;P&gt;In the left-hand list of the Properties window, open "C/C++ Build" and select "Settings" and then the "Tool Settings" tab.&lt;/P&gt;&lt;/LI&gt;&lt;LI&gt;&lt;P&gt;Now choose "MCU C Compiler - Symbols" and add &lt;SPAN style="font-family: courier new,courier;"&gt;&lt;TT&gt;__USE_ROMDIVIDE&lt;/TT&gt;&lt;/SPAN&gt; to the "Defined Symbols".&lt;/P&gt;&lt;/LI&gt;&lt;LI&gt;&lt;P&gt;Now choose "MCU Assembler - General" and add &lt;SPAN style="font-family: courier new,courier;"&gt;&lt;TT&gt; -D__USE_ROMDIVIDE &lt;/TT&gt;&lt;/SPAN&gt; to the "Assembler flags".&lt;/P&gt;&lt;/LI&gt;&lt;LI&gt;&lt;P&gt;Repeat steps 3 and 4 for all Build Configurations (typically Debug and Release)&lt;/P&gt;&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Note :&lt;/STRONG&gt; in some circumstances, in order for your project to link, you may also need to add "&lt;STRONG&gt;--allow-multiple-definition&lt;/STRONG&gt;" to the "Other Options" of the "MCU Linker - Miscellaneous" properties. This should not be necessary in LPCXpresso v7 though.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;H1&gt;Additional Information&lt;/H1&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;&lt;A _jive_internal="true" data-containerid="11529" data-containertype="14" data-objectid="389019" data-objecttype="1" href="https://community.nxp.com/thread/389019"&gt;Enabling ROM divide causes hard fault on LPC11U1x&lt;/A&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 31 Mar 2016 22:38:54 GMT</pubDate>
    <dc:creator>lpcware-support</dc:creator>
    <dc:date>2016-03-31T22:38:54Z</dc:date>
    <item>
      <title>ROM Divide</title>
      <link>https://community.nxp.com/t5/LPCXpresso-IDE-FAQs/ROM-Divide/m-p/473825#M109</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;H1&gt;Background&lt;/H1&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Unlike the Cortex-M3 and M4, the Cortex-M0 does not provide support for divides in hardware. This means that when application code carries out a divide operation, the compiler will insert a call to a library divide function. Thus if your application, or the library routines it invokes, use divide operations, then a certain amount of space in your FLASH will be consumed by one or more library divide functions.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;[The divide function calls generated by the compiler are documented in the run-time section of the &lt;A _jive_internal="true" href="https://community.nxp.com/external-link.jspa?url=http%3A%2F%2Finfocenter.arm.com%2Fhelp%2Findex.jsp%3Ftopic%3D%2Fcom.arm.doc.subset.swdev.abi%2Findex.html"&gt;Application Binary Interface for the ARM Architecture&lt;/A&gt; (commonly known as the AEABI).]&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Certain NXP Cortex-M0 based MCU’s, such as &lt;STRONG&gt;LPC11Axx, LPC11Exx, LPC11Uxx and LPC12xx&lt;/STRONG&gt;, include optimized code in ROM to carry out divide operations. These ROM divide functions operate in "near-constant-time", such that a particular divide function will provide a result in approximately the same amount of cycles, regardless of inputs and the resulting value.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This contrasts with the standard divide library routines that will be pulled from the C library, where the performance will be based on the number of bits in the quotient (the result). For a given set of tests, the ROM divide routine performance is likely to be slower than the fastest performance possible from the standard divide library routines, but quicker than the slowest performance possible from the standard divide library routines.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The other advantage to using the ROM divide library routines is that if your application carries out divide operations, the code overhead of the divide function is removed from your flash (as the routines exist in the library ROM instead).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;H1&gt;Enabling the use of ROM Divide in LPCXpresso IDE&lt;/H1&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In order to make the ROM divide routines as easy to access from application code as possible, LPCXpresso IDE contains support within the project wizards for appropriate MCUs to redirect calls generated by the compiler to the AEABI divide routines directly on to the ROM divide routines.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;To enable this support, ensure that the &lt;STRONG&gt;&lt;TT&gt;"&lt;SPAN style="font-family: courier new,courier;"&gt;Enable use of RomDivide library by compiled code&lt;/SPAN&gt;"&lt;/TT&gt;&lt;/STRONG&gt; option is ticked in in the project wizard options...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/121299i58F6DD7073909F67/image-size/large?v=v2&amp;amp;px=999" title="146820_146820.jpg" alt="146820_146820.jpg" /&gt;&lt;/span&gt;&lt;span class="lia-inline-image-display-wrapper"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/36366iDC5DE60DC7696AEF/image-size/large?v=v2&amp;amp;px=999" title="lpcxpresso_romdivide.jpg" alt="lpcxpresso_romdivide.jpg" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The project wizard will then cause the appropriate compiler, assembler and linker options to be set for your project.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Note&lt;/STRONG&gt; that these project wizard will always create a file called &lt;TT&gt;"&lt;SPAN style="font-family: courier new,courier;"&gt;aeabi_romdiv_patch.s&lt;/SPAN&gt;"&lt;/TT&gt; into the &lt;TT&gt;src&lt;/TT&gt; directory of your new project, which contains the code to redirect the divide function calls onto the ROM divide routines. This will only take effect if the appropriate compiler, assembler and linker options are set.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you decide that you want to switch a project over to using the ROM divide routines when it was created without the support enabled, then you can do so as follows:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;&lt;P&gt;Select the project in the Project Explorer view and then open the Project properties.&lt;/P&gt;&lt;/LI&gt;&lt;LI&gt;&lt;P&gt;In the left-hand list of the Properties window, open "C/C++ Build" and select "Settings" and then the "Tool Settings" tab.&lt;/P&gt;&lt;/LI&gt;&lt;LI&gt;&lt;P&gt;Now choose "MCU C Compiler - Symbols" and add &lt;SPAN style="font-family: courier new,courier;"&gt;&lt;TT&gt;__USE_ROMDIVIDE&lt;/TT&gt;&lt;/SPAN&gt; to the "Defined Symbols".&lt;/P&gt;&lt;/LI&gt;&lt;LI&gt;&lt;P&gt;Now choose "MCU Assembler - General" and add &lt;SPAN style="font-family: courier new,courier;"&gt;&lt;TT&gt; -D__USE_ROMDIVIDE &lt;/TT&gt;&lt;/SPAN&gt; to the "Assembler flags".&lt;/P&gt;&lt;/LI&gt;&lt;LI&gt;&lt;P&gt;Repeat steps 3 and 4 for all Build Configurations (typically Debug and Release)&lt;/P&gt;&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Note :&lt;/STRONG&gt; in some circumstances, in order for your project to link, you may also need to add "&lt;STRONG&gt;--allow-multiple-definition&lt;/STRONG&gt;" to the "Other Options" of the "MCU Linker - Miscellaneous" properties. This should not be necessary in LPCXpresso v7 though.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;H1&gt;Additional Information&lt;/H1&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;&lt;A _jive_internal="true" data-containerid="11529" data-containertype="14" data-objectid="389019" data-objecttype="1" href="https://community.nxp.com/thread/389019"&gt;Enabling ROM divide causes hard fault on LPC11U1x&lt;/A&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 31 Mar 2016 22:38:54 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPCXpresso-IDE-FAQs/ROM-Divide/m-p/473825#M109</guid>
      <dc:creator>lpcware-support</dc:creator>
      <dc:date>2016-03-31T22:38:54Z</dc:date>
    </item>
  </channel>
</rss>

