<?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>topic Re: How to read the Machine State Register (MSR) using the MBD toolbox - MPC5744P? in Model-Based Design Toolbox (MBDT)</title>
    <link>https://community.nxp.com/t5/Model-Based-Design-Toolbox-MBDT/How-to-read-the-Machine-State-Register-MSR-using-the-MBD-toolbox/m-p/1010313#M4050</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello &lt;A class="jx-jive-macro-user" href="https://community.nxp.com/people/rafael.barbosa@chassisbrakes.com"&gt;rafael.barbosa@chassisbrakes.com&lt;/A&gt;‌,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Our Read Registers Block provides access only to peripherals registers. The register you want to read is critical and is one of the process control registers in the PowerPC architecture.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;However, this register may be read using&amp;nbsp;the &lt;STRONG&gt;mfmsr&lt;/STRONG&gt; assembly instruction. For this, you need to insert some custom code.&lt;/P&gt;&lt;P&gt;One way is to&amp;nbsp;create your own S-Function to return the &lt;EM&gt;mfmsrValue&lt;/EM&gt; variable.&lt;/P&gt;&lt;BLOCKQUOTE class="jive_macro_quote jive-quote jive_text_macro"&gt;&lt;P&gt;volatile uint32_t &lt;EM&gt;mfmsrValue&lt;/EM&gt;&lt;SPAN&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/SPAN&gt;;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="color: black; font-size: 13.0pt;"&gt;__asm__&lt;/SPAN&gt;&lt;SPAN style="color: #24292e; background-color: #ffffff;"&gt;( &lt;/SPAN&gt;&lt;SPAN class="" style="color: #032f62; background-color: #ffffff;"&gt;&lt;SPAN class="" style="color: #032f62;"&gt;"&lt;/SPAN&gt;mfmsr %0&lt;SPAN class="" style="color: #032f62;"&gt;"&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN style="color: #24292e; background-color: #ffffff;"&gt; : &lt;/SPAN&gt;&lt;SPAN class="" style="color: #032f62; background-color: #ffffff;"&gt;&lt;SPAN class="" style="color: #032f62;"&gt;"&lt;/SPAN&gt;=r&lt;SPAN class="" style="color: #032f62;"&gt;"&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN style="color: #24292e; background-color: #ffffff;"&gt; (&lt;EM style="color: #3d3d3d;"&gt;mfmsrValue&lt;/EM&gt;&lt;SPAN style="color: #3d3d3d;"&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/SPAN&gt;) );&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="color: #24292e; background-color: #ffffff;"&gt;OUTPUT_PORT = &lt;EM style="color: #3d3d3d;"&gt;mfmsrValue&lt;/EM&gt;&lt;SPAN style="color: #3d3d3d;"&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN&gt;;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;If you want to avoid avoid adding an S-function, you can also&amp;nbsp;add a Data Store Memory Block in your model, call it as &lt;EM&gt;mfmsrValue, &lt;/EM&gt;with DataType uint32 and Storage class: Volatile. Declaring as volatile, for most Simulink Versions it will declare the variable in the code as the name you typed in the Data Store Memory: mfmsrValue.&lt;/P&gt;&lt;P&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/94551iDD974194DB7E1B00/image-size/large?v=v2&amp;amp;px=999" role="button" title="pastedImage_7.png" alt="pastedImage_7.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;After that, in a&amp;nbsp; System Outputs block from Simulink Coder library, you can insert the following code which will read the MSR refisters and store the value in the decalred variable:&lt;/P&gt;&lt;BLOCKQUOTE class="jive_macro_quote jive-quote jive_text_macro"&gt;&lt;P&gt;&lt;SPAN style="color: black; font-size: 13.0pt;"&gt;__asm__&lt;/SPAN&gt;&lt;SPAN style="color: #24292e; background-color: #ffffff;"&gt;(&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN class="" style="color: #032f62; background-color: #ffffff;"&gt;&lt;SPAN class="" style="color: #032f62;"&gt;"&lt;/SPAN&gt;mfmsr %0&lt;SPAN class="" style="color: #032f62;"&gt;"&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN style="color: #24292e; background-color: #ffffff;"&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;:&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN class="" style="color: #032f62; background-color: #ffffff;"&gt;&lt;SPAN class="" style="color: #032f62;"&gt;"&lt;/SPAN&gt;=r&lt;SPAN class="" style="color: #032f62;"&gt;"&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN style="color: #24292e; background-color: #ffffff;"&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;(&lt;EM style="color: #3d3d3d;"&gt;mfmsrValue&lt;/EM&gt;&lt;SPAN style="color: #3d3d3d;"&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/SPAN&gt;) );&lt;/SPAN&gt;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you make sure that the following blocks will be called exactly in this order (System Outputs first, followed by mfmsrValue Read) you will have the value from the desired register in the Data Store Memory.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="color: #24292e; background-color: #ffffff;"&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="pastedImage_10.png"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/94634iE8F8F63A2AB78328/image-size/large?v=v2&amp;amp;px=999" role="button" title="pastedImage_10.png" alt="pastedImage_10.png" /&gt;&lt;/span&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="color: #24292e; background-color: #ffffff;"&gt;Hope this helps,&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="color: #24292e; background-color: #ffffff;"&gt;Marius&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 19 Nov 2019 15:41:39 GMT</pubDate>
    <dc:creator>mariuslucianand</dc:creator>
    <dc:date>2019-11-19T15:41:39Z</dc:date>
    <item>
      <title>How to read the Machine State Register (MSR) using the MBD toolbox - MPC5744P?</title>
      <link>https://community.nxp.com/t5/Model-Based-Design-Toolbox-MBDT/How-to-read-the-Machine-State-Register-MSR-using-the-MBD-toolbox/m-p/1010312#M4049</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #51626f; background-color: #ffffff;"&gt;I am using the Devkit MPC5744P and the Model Based Design Toolbox 3.0.0.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #51626f; background-color: #ffffff;"&gt;I can not find the MSR register&amp;nbsp;using the "Read Registers Block".&lt;BR /&gt;Is there a way to read it in the Model Based Design?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #51626f; background-color: #ffffff;"&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/94633iD71B8ACCA1969787/image-size/large?v=v2&amp;amp;px=999" role="button" title="pastedImage_1.png" alt="pastedImage_1.png" /&gt;&lt;/span&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #51626f; background-color: #ffffff;"&gt;Kind Regards, Rafael&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 19 Nov 2019 14:36:46 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Model-Based-Design-Toolbox-MBDT/How-to-read-the-Machine-State-Register-MSR-using-the-MBD-toolbox/m-p/1010312#M4049</guid>
      <dc:creator>rafael_barbosa</dc:creator>
      <dc:date>2019-11-19T14:36:46Z</dc:date>
    </item>
    <item>
      <title>Re: How to read the Machine State Register (MSR) using the MBD toolbox - MPC5744P?</title>
      <link>https://community.nxp.com/t5/Model-Based-Design-Toolbox-MBDT/How-to-read-the-Machine-State-Register-MSR-using-the-MBD-toolbox/m-p/1010313#M4050</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello &lt;A class="jx-jive-macro-user" href="https://community.nxp.com/people/rafael.barbosa@chassisbrakes.com"&gt;rafael.barbosa@chassisbrakes.com&lt;/A&gt;‌,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Our Read Registers Block provides access only to peripherals registers. The register you want to read is critical and is one of the process control registers in the PowerPC architecture.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;However, this register may be read using&amp;nbsp;the &lt;STRONG&gt;mfmsr&lt;/STRONG&gt; assembly instruction. For this, you need to insert some custom code.&lt;/P&gt;&lt;P&gt;One way is to&amp;nbsp;create your own S-Function to return the &lt;EM&gt;mfmsrValue&lt;/EM&gt; variable.&lt;/P&gt;&lt;BLOCKQUOTE class="jive_macro_quote jive-quote jive_text_macro"&gt;&lt;P&gt;volatile uint32_t &lt;EM&gt;mfmsrValue&lt;/EM&gt;&lt;SPAN&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/SPAN&gt;;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="color: black; font-size: 13.0pt;"&gt;__asm__&lt;/SPAN&gt;&lt;SPAN style="color: #24292e; background-color: #ffffff;"&gt;( &lt;/SPAN&gt;&lt;SPAN class="" style="color: #032f62; background-color: #ffffff;"&gt;&lt;SPAN class="" style="color: #032f62;"&gt;"&lt;/SPAN&gt;mfmsr %0&lt;SPAN class="" style="color: #032f62;"&gt;"&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN style="color: #24292e; background-color: #ffffff;"&gt; : &lt;/SPAN&gt;&lt;SPAN class="" style="color: #032f62; background-color: #ffffff;"&gt;&lt;SPAN class="" style="color: #032f62;"&gt;"&lt;/SPAN&gt;=r&lt;SPAN class="" style="color: #032f62;"&gt;"&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN style="color: #24292e; background-color: #ffffff;"&gt; (&lt;EM style="color: #3d3d3d;"&gt;mfmsrValue&lt;/EM&gt;&lt;SPAN style="color: #3d3d3d;"&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/SPAN&gt;) );&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="color: #24292e; background-color: #ffffff;"&gt;OUTPUT_PORT = &lt;EM style="color: #3d3d3d;"&gt;mfmsrValue&lt;/EM&gt;&lt;SPAN style="color: #3d3d3d;"&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN&gt;;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;If you want to avoid avoid adding an S-function, you can also&amp;nbsp;add a Data Store Memory Block in your model, call it as &lt;EM&gt;mfmsrValue, &lt;/EM&gt;with DataType uint32 and Storage class: Volatile. Declaring as volatile, for most Simulink Versions it will declare the variable in the code as the name you typed in the Data Store Memory: mfmsrValue.&lt;/P&gt;&lt;P&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/94551iDD974194DB7E1B00/image-size/large?v=v2&amp;amp;px=999" role="button" title="pastedImage_7.png" alt="pastedImage_7.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;After that, in a&amp;nbsp; System Outputs block from Simulink Coder library, you can insert the following code which will read the MSR refisters and store the value in the decalred variable:&lt;/P&gt;&lt;BLOCKQUOTE class="jive_macro_quote jive-quote jive_text_macro"&gt;&lt;P&gt;&lt;SPAN style="color: black; font-size: 13.0pt;"&gt;__asm__&lt;/SPAN&gt;&lt;SPAN style="color: #24292e; background-color: #ffffff;"&gt;(&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN class="" style="color: #032f62; background-color: #ffffff;"&gt;&lt;SPAN class="" style="color: #032f62;"&gt;"&lt;/SPAN&gt;mfmsr %0&lt;SPAN class="" style="color: #032f62;"&gt;"&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN style="color: #24292e; background-color: #ffffff;"&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;:&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN class="" style="color: #032f62; background-color: #ffffff;"&gt;&lt;SPAN class="" style="color: #032f62;"&gt;"&lt;/SPAN&gt;=r&lt;SPAN class="" style="color: #032f62;"&gt;"&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN style="color: #24292e; background-color: #ffffff;"&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;(&lt;EM style="color: #3d3d3d;"&gt;mfmsrValue&lt;/EM&gt;&lt;SPAN style="color: #3d3d3d;"&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/SPAN&gt;) );&lt;/SPAN&gt;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you make sure that the following blocks will be called exactly in this order (System Outputs first, followed by mfmsrValue Read) you will have the value from the desired register in the Data Store Memory.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="color: #24292e; background-color: #ffffff;"&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="pastedImage_10.png"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/94634iE8F8F63A2AB78328/image-size/large?v=v2&amp;amp;px=999" role="button" title="pastedImage_10.png" alt="pastedImage_10.png" /&gt;&lt;/span&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="color: #24292e; background-color: #ffffff;"&gt;Hope this helps,&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="color: #24292e; background-color: #ffffff;"&gt;Marius&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 19 Nov 2019 15:41:39 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Model-Based-Design-Toolbox-MBDT/How-to-read-the-Machine-State-Register-MSR-using-the-MBD-toolbox/m-p/1010313#M4050</guid>
      <dc:creator>mariuslucianand</dc:creator>
      <dc:date>2019-11-19T15:41:39Z</dc:date>
    </item>
    <item>
      <title>Re: How to read the Machine State Register (MSR) using the MBD toolbox - MPC5744P?</title>
      <link>https://community.nxp.com/t5/Model-Based-Design-Toolbox-MBDT/How-to-read-the-Machine-State-Register-MSR-using-the-MBD-toolbox/m-p/1010314#M4051</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello Marius,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you for the response.&lt;/P&gt;&lt;P&gt;I tried to implement using the&amp;nbsp;&lt;SPAN style="color: #51626f; background-color: #ffffff;"&gt;Data Store Memory Block approach and it works good.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #51626f; background-color: #ffffff;"&gt;Regards, Rafael&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 20 Nov 2019 08:27:27 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Model-Based-Design-Toolbox-MBDT/How-to-read-the-Machine-State-Register-MSR-using-the-MBD-toolbox/m-p/1010314#M4051</guid>
      <dc:creator>rafael_barbosa</dc:creator>
      <dc:date>2019-11-20T08:27:27Z</dc:date>
    </item>
  </channel>
</rss>

