<?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>Model-Based Design Toolbox (MBDT)のトピックHow to manage the memory using the simulink?</title>
    <link>https://community.nxp.com/t5/Model-Based-Design-Toolbox-MBDT/How-to-manage-the-memory-using-the-simulink/m-p/671392#M382</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Daniel,&lt;/P&gt;&lt;P&gt;Friend,I feel like i am a little confused.&lt;SPAN style="color: #ff0000; font-size: 22px;"&gt;&lt;STRONG&gt;How to manage the memory using the simulink?&amp;nbsp;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;I generate the C- code shown as below:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;/* S-Function (MemWrite_564xl_fcn): '&amp;lt;Root&amp;gt;/DataMemWrite' */&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;/* Memory Address Write */&lt;BR /&gt;&amp;nbsp;/* Memory Address : Base Address + Offset */&lt;BR /&gt;&amp;nbsp;/* Memory Address : 0x40002C88; */&lt;BR /&gt;{&lt;BR /&gt;&amp;nbsp;uint32_T * (write_mem_address);&lt;BR /&gt;&amp;nbsp;write_mem_address = (uint32_T *)0x40002C88;&lt;BR /&gt;&amp;nbsp;*(write_mem_address) = Calibiate1;&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;What you means is that the Address that i write has been other program occupied.&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #ff0000; font-size: 22px;"&gt;&lt;STRONG&gt;How can i make sure which memory segment has&amp;nbsp;not been used?&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #ff0000; font-size: 22px;"&gt;&lt;STRONG&gt;The attachment is my Model.&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Original Attachment has been moved to: &lt;A _jive_internal="true" href="https://community.nxp.com/docs/DOC-338669"&gt;CCP_CAN.mdl.zip&lt;/A&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 17 Jul 2017 03:26:32 GMT</pubDate>
    <dc:creator>edenli</dc:creator>
    <dc:date>2017-07-17T03:26:32Z</dc:date>
    <item>
      <title>How to manage the memory using the simulink?</title>
      <link>https://community.nxp.com/t5/Model-Based-Design-Toolbox-MBDT/How-to-manage-the-memory-using-the-simulink/m-p/671392#M382</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Daniel,&lt;/P&gt;&lt;P&gt;Friend,I feel like i am a little confused.&lt;SPAN style="color: #ff0000; font-size: 22px;"&gt;&lt;STRONG&gt;How to manage the memory using the simulink?&amp;nbsp;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;I generate the C- code shown as below:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;/* S-Function (MemWrite_564xl_fcn): '&amp;lt;Root&amp;gt;/DataMemWrite' */&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;/* Memory Address Write */&lt;BR /&gt;&amp;nbsp;/* Memory Address : Base Address + Offset */&lt;BR /&gt;&amp;nbsp;/* Memory Address : 0x40002C88; */&lt;BR /&gt;{&lt;BR /&gt;&amp;nbsp;uint32_T * (write_mem_address);&lt;BR /&gt;&amp;nbsp;write_mem_address = (uint32_T *)0x40002C88;&lt;BR /&gt;&amp;nbsp;*(write_mem_address) = Calibiate1;&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;What you means is that the Address that i write has been other program occupied.&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #ff0000; font-size: 22px;"&gt;&lt;STRONG&gt;How can i make sure which memory segment has&amp;nbsp;not been used?&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #ff0000; font-size: 22px;"&gt;&lt;STRONG&gt;The attachment is my Model.&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Original Attachment has been moved to: &lt;A _jive_internal="true" href="https://community.nxp.com/docs/DOC-338669"&gt;CCP_CAN.mdl.zip&lt;/A&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 17 Jul 2017 03:26:32 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Model-Based-Design-Toolbox-MBDT/How-to-manage-the-memory-using-the-simulink/m-p/671392#M382</guid>
      <dc:creator>edenli</dc:creator>
      <dc:date>2017-07-17T03:26:32Z</dc:date>
    </item>
    <item>
      <title>Re: How to manage the memory using the simulink?</title>
      <link>https://community.nxp.com/t5/Model-Based-Design-Toolbox-MBDT/How-to-manage-the-memory-using-the-simulink/m-p/671393#M383</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi &lt;A class="jx-jive-macro-user" href="https://community.nxp.com/people/edenli"&gt;edenli&lt;/A&gt;‌,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;There are at least 2 methods i could think of right now:&lt;/P&gt;&lt;P&gt;- #1: quick in and dirty is &lt;STRONG&gt;to declare a reserved buffer in Simulink with a size you control&lt;/STRONG&gt;. Since in Simulink you control the read/write into such buffer you could easily implement what you want with writes and reads to any specific index in the buffer.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Am saying is a quick and dirty since you do not control the start address of the buffer - depending on your Simulink modification that might change and you might need to re-adapt the start address of the DataMemWrite/Read Blocks (the offsets remains unchanged). If you use instead DataMemWrite/Read the standard Simulink Read/WriteStore blocks - then everything would be ok and you could forget about address changing due to adding new stuff in the model.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;How to declare a 100 uint32 size buffer called myReservedSpace in Simulink:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="pastedImage_1.png"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/26158iFAC0BBF9B57EE840/image-size/large?v=v2&amp;amp;px=999" role="button" title="pastedImage_1.png" alt="pastedImage_1.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="pastedImage_2.png"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/26228i574BC89FF864FB3F/image-size/large?v=v2&amp;amp;px=999" role="button" title="pastedImage_2.png" alt="pastedImage_2.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;How to implement the model&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="pastedImage_4.png"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/26289iF1C55ACBF4EF3CC1/image-size/large?v=v2&amp;amp;px=999" role="button" title="pastedImage_4.png" alt="pastedImage_4.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;How to check the memory allocation:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="pastedImage_3.png"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/26241i33D5B065F6C30DBD/image-size/large?v=v2&amp;amp;px=999" role="button" title="pastedImage_3.png" alt="pastedImage_3.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;- #2: the "profi" method would be &lt;STRONG&gt;to use a reserved memory area in the SRAM that have fixed start address and size&lt;/STRONG&gt;.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;For that you need to modify the Toolbox standard linker command files ( from here:&amp;nbsp;&lt;SPAN style="font-family: 'courier new', courier, monospace;"&gt;{toolbox install dir}\rappid564xl\src\cw_specific_files\&lt;/SPAN&gt;) by spliting the existing SRAM memory into 3 (right now there are 2 areas). So you need to add a new one: before &lt;STRONG&gt;int_sram&lt;/STRONG&gt; or after &lt;STRONG&gt;int_sram&lt;/STRONG&gt;. The &lt;STRONG&gt;stack_ram&lt;/STRONG&gt; would be better to be kept last in order to avoid stack overflow issues.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="pastedImage_7.png"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/26518iDCCE4F02C37E52C9/image-size/large?v=v2&amp;amp;px=999" role="button" title="pastedImage_7.png" alt="pastedImage_7.png" /&gt;&lt;/span&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Here is an example:&amp;nbsp;&lt;A class="link-titled" href="https://stackoverflow.com/questions/8870548/how-can-i-make-an-empty-section-with-gnu-ld" title="https://stackoverflow.com/questions/8870548/how-can-i-make-an-empty-section-with-gnu-ld"&gt;cortex m3 - How can I make an empty section with GNU ld? - Stack Overflow&lt;/A&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Once you have defined the area, you could take the start address of it an then using the DataMemWrite/Read you could control what you place in the that area.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Hope this helps!&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Daniel&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 17 Jul 2017 09:12:07 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Model-Based-Design-Toolbox-MBDT/How-to-manage-the-memory-using-the-simulink/m-p/671393#M383</guid>
      <dc:creator>Daniel_Popa</dc:creator>
      <dc:date>2017-07-17T09:12:07Z</dc:date>
    </item>
  </channel>
</rss>

