⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 impdet24.htm

📁 ST20 Embedded Toolset R2.0.5用于开发基于ST20芯片机顶盒软件的开发平台,2.0.5版本,国内找不到的.在国外论坛上花了N天才找到!
💻 HTM
字号:
<html>

<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<meta name="GENERATOR" content="Quadralay WebWorks Publisher Professional Edition 6.0.5">
<meta name="TEMPLATEBASE" content="book_html">
<meta name="LASTUPDATED" content="12/04/03 16:06:26">
<title>13.10 Device memory access</title>

<STYLE TYPE="text/css">
<!--
	span.Signal { text-transform: uppercase; font-family: Verdana }
-->
</STYLE>

</head>

<body link="#3366CC" vlink="#9999CC" text="#000000" alink="#0000CC" bgcolor="#FFFFFF"
background="images/backgrnd.gif">

<p><img src="images/stlogo.gif" width="106" height="83" align="left"
alt="logo here!"> </p>

<table width="331" border="0" align="right" cellpadding="0" cellspacing="0">
  <tr>
    <td><a href="a_refman.htm"><img src="images/navtoc.gif" width="84" height="23"
    border="0" alt="TOC"> </a></td>
    <td><a href="impdet23.htm"><img src="images/navprev.gif" width="80" height="23"
    border="0" alt="PREV"> </a></td>
    <td><a href="impdet25.htm"><img src="images/navnext.gif" width="83" height="23"
    border="0" alt="NEXT"> </a></td>
    <td><a href="a_refmaa.htm"><img src="images/navidx.gif" width="84" height="23"
    border="0" alt="INDEX"> </a></td>
  </tr>
</table>

<p><br clear="all">
</p>

<hr align="left">

<blockquote>
<h2>
  <a name="1205227"> </a><font color="#003366"  face="Verdana, Arial, Helvetica, sans-serif">13.10 	 Device memory access</font>
</h2><hr>


<p>
  <a name="1205228"> </a><font size=2  face="Verdana, Arial, Helvetica, sans-serif">In the ST20C2 instruction set there are two classes of memory access instructions, normal accesses and "device" accesses. Device memory accesses behave slightly differently to normal accesses, and it is important to use the right one, especially when accessing peripherals or using a cache.</font>
</p>


<p>
  <a name="1205229"> </a><font size=2  face="Verdana, Arial, Helvetica, sans-serif">Device accesses are performed using a number of special instructions, collectively referred to as device instructions:</font>
</p>

<ul>
<p>  <font size=2  face="Verdana, Arial, Helvetica, sans-serif"><li ><a name="1205230"> </a><font size=2 face=Courier><strong>devlb</strong></font> and <font size=2 face=Courier><strong>devsb</strong></font> - read and write a byte of memory,</font></p>
<p>  <font size=2  face="Verdana, Arial, Helvetica, sans-serif"><li ><a name="1205231"> </a><font size=2 face=Courier><strong>devls</strong></font> and <font size=2 face=Courier><strong>devss</strong></font> - read and write a 16-bit quantity of memory,</font></p>
<p>  <font size=2  face="Verdana, Arial, Helvetica, sans-serif"><li ><a name="1205232"> </a><font size=2 face=Courier><strong>devlw</strong></font> and <font size=2 face=Courier><strong>devsw</strong></font> - read and write a 32-bit word of memory,</font></p>
<p>  <font size=2  face="Verdana, Arial, Helvetica, sans-serif"><li ><a name="1205233"> </a><font size=2 face=Courier><strong>devmove</strong></font> - move a block of memory (both source and destination addresses use device accesses).</font></p>
</ul>

<p>
  <a name="1205234"> </a><font size=2  face="Verdana, Arial, Helvetica, sans-serif">All other instructions which read or write to memory generate "normal" memory accesses.</font>
</p>


<p>
  <a name="1205235"> </a><font size=2  face="Verdana, Arial, Helvetica, sans-serif">A device access has a number of special attributes.</font>
</p>

<ul>
<p>  <font size=2  face="Verdana, Arial, Helvetica, sans-serif"><li ><a name="1205236"> </a>When accessing the internal peripheral space, device instructions use the peripheral bus rather than the memory bus. All on-chip peripherals within the internal peripheral space are connected to the peripheral bus, so device instructions must be used to access them.</font></p>
<p>  <font size=2  face="Verdana, Arial, Helvetica, sans-serif"><li ><a name="1205237"> </a>When accessing cacheable memory, device instructions always bypass the cache, and access memory directly. The data accessed is not loaded into the cache. Even if the memory location being accessed has been cached, a device access to that location accesses memory directly, and the data in the cache is not updated.</font></p>
<p>  <font size=2  face="Verdana, Arial, Helvetica, sans-serif"><li ><a name="1205238"> </a>Device instructions prevent the CPU performing any optimizations which may be unsafe when applied to peripheral registers. In particular, any device writes must complete before the next instruction is executed, while a normal memory write may be buffered.</font></p>
</ul>

<p>
  <a name="1205239"> </a><font size=2  face="Verdana, Arial, Helvetica, sans-serif">In general, there are two cases when a device instruction must be used:</font>
</p>

<ul>
<p>  <font size=2  face="Verdana, Arial, Helvetica, sans-serif"><li ><a name="1205240"> </a>when accessing on-chip peripherals in the internal peripheral space,</font></p>
  <dl>
    <dt> <a name="1209670"> </a><font size=2  face="Verdana, Arial, Helvetica, sans-serif">The address of the internal peripheral space varies between devices, but is usually between <font size=2 face=Courier><strong>0x00000000</strong></font> and <font size=2 face=Courier><strong>0x3fffffff</strong></font> or <font size=2 face=Courier><strong>0x20000000</strong></font> to <font size=2 face=Courier><strong>0x3fffffff</strong></font>.</font>
  </dl>
<p>  <font size=2  face="Verdana, Arial, Helvetica, sans-serif"><li ><a name="1205241"> </a>when accessing cacheable memory which should not be loaded into the cache.</font></p>
  <dl>
    <dt> <a name="1209674"> </a><font size=2  face="Verdana, Arial, Helvetica, sans-serif">The most common case where this is useful is when memory is written to by a peripheral using DMA. DMA memory accesses are always direct to memory, ignoring the cache. So when the CPU accesses the memory location, it is important it does not read a value from the cache rather than memory. This is because the cache would not be updated when the DMA access was performed and so could contain "stale" or old data.</font>
    <dt> <a name="1205242"> </a><font size=2  face="Verdana, Arial, Helvetica, sans-serif">A beneficial side-effect of not caching data in this way is that frequently data written into memory using DMA is read once, immediately written to another location (possibly an output peripheral) and never read again. Thus loading the data into cache would be of no benefit, and would prevent useful data being cached.</font>
    <dt> <a name="1205243"> </a><font size=2  face="Verdana, Arial, Helvetica, sans-serif">When using memory in this way it is necessary to be aware of the cache alignment of the data. When a word is read from cacheable memory using a normal memory access instruction, not only the word accessed is brought into the cache, but also the surrounding words, to fill the whole cache line. Later when the cache line is discarded, if any word within the cache line has been written to, the whole cache line is written out into memory. If one of the adjacent words had been written to using a device instruction (or by a peripheral performing DMA) the cache write back would overwrite this word with old data.</font>
    <dt> <a name="1205244"> </a><font size=2  face="Verdana, Arial, Helvetica, sans-serif">The easiest way to avoid this problem is to ensure that all buffers accessed using device instructions are aligned to the size of a cache line, and are extended so their size is a multiple of the cache line size. The alignment can be achieved by placing the buffer in a named section, and then use the <font size=2 face=Courier><strong>alignment </strong></font>option to the <font size=2 face=Courier><strong>place</strong></font> command.</font>
    <dt> <a name="1205245"> </a><font size=2  face="Verdana, Arial, Helvetica, sans-serif">(An alternative to using device instructions to bypass the cache is to use the "cacheability control" registers of the cache to reset the device hardware. See the appropriate device datasheet for details. This allows entire blocks of memory to be marked as "not cacheable" and access is then performed using normal memory access).</font>
  </dl>
</ul>

<p>
  <a name="1205246"> </a><font size=2  face="Verdana, Arial, Helvetica, sans-serif">A memory location should always be accessed using only device or non-device instructions, never a mixture of the two. Failure to follow this rule can lead to some very hard-to-diagnose problems.</font>
</p>
</blockquote>

<hr>



<table width="331" border="0" align="left" cellpadding="0" cellspacing="0">
  <tr>
    <td><a href="a_refman.htm"><img src="images/navtoc.gif" width="84" height="23"
    border="0" alt="TOC"> </a></td>
    <td><a href="impdet23.htm"><img src="images/navprev.gif" width="80" height="23"
    border="0" alt="PREV"> </a></td>
    <td><a href="impdet25.htm"><img src="images/navnext.gif" width="83" height="23"
    border="0" alt="NEXT"> </a></td>
    <td><a href="a_refmaa.htm"><img src="images/navidx.gif" width="84" height="23"
    border="0" alt="INDEX"> </a></td>
  </tr>
</table>
<font size=1 face="Verdana, Arial, Helvetica, sans-serif">&nbsp; &copy; 2001, 2002, 2003 STMicroelectronics. All Rights Reserved.<br>
&nbsp; ADCS 7250966F</font>
</body>
</html>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -