<?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 Memory Protection Unit (MPU) and RAM STACK overflow Monitor in S12 / MagniV Microcontrollers</title>
    <link>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/Memory-Protection-Unit-MPU-and-RAM-STACK-overflow-Monitor/m-p/202416#M8206</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt;&lt;P&gt;&lt;SPAN style="font-size: 2;"&gt;Hi,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 2;"&gt;I want to configure The Memory Protection Unit S12XMPUV1 to accomplish the following: Capture any illicit writes to the RAM containing the XGATE code. Capture any illicit writes by the XGATE to RAM not allocated to it. Capture any illicit writes by the S12 core to RAM not allocated to it. Capture any attempt by XGATE to execute code from FLASH/RAM not allocated to it for execution. Capture any attempt by S12 core to execute code from FLASH/RAM not allocated to it for execution.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 2;"&gt;can somebody give me a rough draft of the sequence on how this is done? i also want a function to&amp;nbsp;MONITOR STACK OVERFLOW&amp;nbsp;aside from capturing any illegal access errors from the MPU.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 2;"&gt;any algo, flowchart or rough diagram is appreciated...&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 2;"&gt;thanks,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 2;"&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 2;"&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 2;"&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 13 Mar 2008 12:05:10 GMT</pubDate>
    <dc:creator>Xbot</dc:creator>
    <dc:date>2008-03-13T12:05:10Z</dc:date>
    <item>
      <title>Memory Protection Unit (MPU) and RAM STACK overflow Monitor</title>
      <link>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/Memory-Protection-Unit-MPU-and-RAM-STACK-overflow-Monitor/m-p/202416#M8206</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt;&lt;P&gt;&lt;SPAN style="font-size: 2;"&gt;Hi,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 2;"&gt;I want to configure The Memory Protection Unit S12XMPUV1 to accomplish the following: Capture any illicit writes to the RAM containing the XGATE code. Capture any illicit writes by the XGATE to RAM not allocated to it. Capture any illicit writes by the S12 core to RAM not allocated to it. Capture any attempt by XGATE to execute code from FLASH/RAM not allocated to it for execution. Capture any attempt by S12 core to execute code from FLASH/RAM not allocated to it for execution.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 2;"&gt;can somebody give me a rough draft of the sequence on how this is done? i also want a function to&amp;nbsp;MONITOR STACK OVERFLOW&amp;nbsp;aside from capturing any illegal access errors from the MPU.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 2;"&gt;any algo, flowchart or rough diagram is appreciated...&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 2;"&gt;thanks,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 2;"&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 2;"&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 2;"&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 13 Mar 2008 12:05:10 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/Memory-Protection-Unit-MPU-and-RAM-STACK-overflow-Monitor/m-p/202416#M8206</guid>
      <dc:creator>Xbot</dc:creator>
      <dc:date>2008-03-13T12:05:10Z</dc:date>
    </item>
    <item>
      <title>Re: Memory Protection Unit (MPU) and RAM STACK overflow Monitor</title>
      <link>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/Memory-Protection-Unit-MPU-and-RAM-STACK-overflow-Monitor/m-p/202417#M8207</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt;I suggest that you begin by inverting your specification. The MPU is a permission-grant approach rather than a blocking system. So you need to define what access are allowed rather than what is not allowed.&lt;/DIV&gt;&lt;DIV&gt;The MPU is always active, and at reset allows all access to both cores. The CPU has a choice of Supervisor or User state where User state has some additional restrictions:&lt;/DIV&gt;&lt;DIV&gt;Software cannot set or clear system interrupt enables (X, I), stop enable (S) or change interrupt priority (IPL[0..2])&lt;BR /&gt;Software cannot execute WAI or STOP op-codes&lt;BR /&gt;No opcode can change the user state bit (RTI, PULC, EXG etc.)&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;In terms of a flow, I'd suggest something like:&lt;/DIV&gt;&lt;DIV&gt;1/ Set up handlers for MPU errors - XGATE and CPU&lt;/DIV&gt;&lt;DIV&gt;If you make an error when setting up the MPU you would like to be able to recover gracefuly&lt;/DIV&gt;&lt;DIV&gt;2/ Identify the physical ranges that are allowed&lt;/DIV&gt;&lt;DIV&gt;You can get this information from the linker, but you probably need to be fairly close to completing the code to make sure that all of the relevant groups of memory are identified. Don't forget to include libraries and peripheral spaces.&lt;/DIV&gt;&lt;DIV&gt;3/ After reset, create a function that initialises the MPU to the values that you have defined.&lt;/DIV&gt;&lt;DIV&gt;You'll need to define XGATE access for its code and data space. If you have shared memory then you can use a single descriptor and allocate both CPU and XGATE access.&lt;/DIV&gt;&lt;DIV&gt;If you have an OS or other complex approach on the CPU you may find that you need to dynamically change the settings of the descriptors for the CPU.&lt;/DIV&gt;&lt;DIV&gt;In most cases you will want the CPU to&amp;nbsp;use User state so make sure that you identify areas of code that need the restricted access types and put these in a special handler (interrupt).&lt;/DIV&gt;&lt;DIV&gt;4/ Decide how you want to enter User state and then set the U bit.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 13 Mar 2008 19:18:02 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/Memory-Protection-Unit-MPU-and-RAM-STACK-overflow-Monitor/m-p/202417#M8207</guid>
      <dc:creator>Steve</dc:creator>
      <dc:date>2008-03-13T19:18:02Z</dc:date>
    </item>
  </channel>
</rss>

