1<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> 2<HTML> 3<HEAD> 4<META http-equiv="Content-Type" content="text/html; charset=utf-8"> 5<META name="GENERATOR" content="IBM WebSphere Studio Homepage Builder Version 7.0.1.0 for Windows"> 6<META http-equiv="Content-Style-Type" content="text/css"> 7<TITLE>MI_DmaCopy</TITLE> 8<LINK rel="stylesheet" href="../../css/nitro.css" type="text/css"> 9</HEAD> 10<BODY> 11<H1 align="left">MI_DmaCopy* <IMG src="../../image/NTR.gif" align="middle"><IMG src="../../image/TWL.gif" align="middle"></H1> 12<H2>Syntax</H2> 13<DL> 14<DD><CODE>#include <nitro/mi.h></CODE><BR> <BR> <CODE>void MI_DmaCopy32( u32 dmaNo,<BR> const void* src,<BR> void* dest,<BR> u32 size );</CODE><BR> <BR> <CODE>void MI_DmaCopy32_SetUp( u32 dmaNo,<BR> const void* src,<BR> void* dest,<BR> u32 size );</CODE><BR> <BR> <CODE>void MI_DmaCopy16( u32 dmaNo,<BR> const void* src,<BR> void* dest,<BR> u32 size );</CODE><BR> <BR> <CODE>void MI_DmaCopy16_SetUp( u32 dmaNo,<BR> const void* src,<BR> void* dest,<BR> u32 size );</CODE><BR> <BR> <CODE>void MI_DmaCopy32Async( u32 dmaNo,<BR> const void* src,<BR> void* dest,<BR> u32 size,<BR> MIDmaCallback callback,<BR> void* arg );</CODE><BR> <BR> <CODE>void MI_DmaCopy32Async_SetUp( u32 dmaNo,<BR> const void* src,<BR> void* dest,<BR> u32 size,<BR> MIDmaCallback callback,<BR> void* arg );</CODE><BR> <BR> <CODE>void MI_DmaCopy16Async( u32 dmaNo,<BR> const void* src,<BR> void* dest,<BR> u32 size,<BR> MIDmaCallback callback,<BR> void* arg );</CODE><BR> <BR> <CODE>void MI_DmaCopy16Async_SetUp( u32 dmaNo,<BR> const void* src,<BR> void* dest,<BR> u32 size,<BR> MIDmaCallback callback,<BR> void* arg );</CODE><BR> 15</DL> 16<H2>Arguments</H2> 17<TABLE border="1" width="100%"> 18 <TBODY> 19 <TR> 20<TD width="13%"><EM><STRONG>dmaNo</STRONG></EM></TD> 21<TD width="87%">DMA channel used.</TD> 22 </TR> 23 <TR> 24<TD width="13%"><EM><STRONG>src</STRONG></EM></TD> 25<TD width="87%">Transfer source address.</TD> 26 </TR> 27 <TR> 28<TD width="13%"><EM><STRONG>dest</STRONG></EM></TD> 29<TD width="87%">Transfer destination address.</TD> 30 </TR> 31 <TR> 32<TD><EM><STRONG>size</STRONG></EM></TD> 33<TD>Transfer size.</TD> 34 </TR> 35 <TR> 36<TD><EM><STRONG>callback</STRONG></EM></TD> 37<TD>Callback when DMA ends.</TD> 38 </TR> 39 <TR> 40<TD><EM><STRONG>arg</STRONG></EM></TD> 41<TD>Callback argument when DMA ends.</TD> 42 </TR> 43 </TBODY> 44</TABLE> 45<H2>Return Values</H2> 46<P>None.</P> 47<H2>Description</H2> 48<P>Uses DMA to copy.</P> 49<P>The <CODE>*_SetUp</CODE> functions only configure the given settings without actually performing DMA. To actually start DMA, call the <A href="MI_DmaRestart.html"><CODE>MI_DmaRestart</CODE></A> function.</P> 50<P>The <CODE>MI_DmaCopy16*</CODE> functions copy in 16-bit units. Both the transfer source address and the transfer destination address must be 2-byte aligned.</P> 51<P>The <CODE>MI_DmaCopy32*</CODE> functions copy in 32-bit units. Both the transfer source address and the transfer destination address must be 4-byte aligned.</P> 52<P><code>MI_DmaCopy16</code> and <code>MI_DmaCopy32</code> wait inside the function until DMA completes. The <code>MI_DmaCopy16Async*</code> and <code>MI_DmaCopy32Async*</code> functions call a callback function when DMA ends. The callback, <SPAN class="argument">callback</SPAN>, is a <code>MIDmaCallback</code> type (a <code>void</code> type function that takes one <code>void*</code> argument). The <SPAN class="argument">callback</SPAN> argument is called from the system DMA interrupt handler and therefore is called even if interrupts are prohibited.</P> 53<P>To achieve maximum functionality, you need to understand how to use Async-type APIs.</P> 54<P>The following is an example of a function name, <code>Call_BackGroundJob_with_DMA</code>, that is placed in TCM.</P> 55<P>The following processes are performed.</P> 56<UL> 57<LI>Data transfer using DMA in the function begins. 58<LI>When the DMA ends, <code>isDmaFinished</code> will be set to <code>TRUE</code> within <code>callback()</code>. 59<LI>It is possible to poll <CODE>isDmaFinished</CODE> as a completion flag and call the <CODE>BackGroundJob</CODE> function repeatedly until DMA completes. 60</UL> 61<P>However, you must consider the following to have this process proceed as intended.</P> 62<UL> 63<LI>If <code>isDmaFinished</code> is not in TCM, stalling occurs during the <code>while(!isDmaFinished)</code> check. 64<LI>Stalling occurs if the <code>BackGroundJob</code> function accesses the ARM bus. 65<LI>In many cases, the stack also needs to be allocated in TCM. (The stack is allocated in DTCM with the default SDK configuration.) 66<LI>If this function is located in main memory, stalling occurs when DMA starts. Therefore, the <code>BackGroundJob</code> function cannot be called continuously. 67</UL> 68<BLOCKQUOTE style="background-color: #ffffcc"> 69<PRE><CODE> 70//--- Sample code (this code must be in ITCM) 71void Call_BackGroundJob_with_DMA(void) 72{ 73 vu32 isDmaFinished = FALSE; 74 : 75 MI_DmaCopy32Async( dmaNo, srcArea, destArea, dataSize, callback, (void*)&isDmaFinished ); 76 while( !isDmaFinished ){ BackGroundJob(); } 77 : 78} 79 80void callback( void* arg ) 81{ 82 *(vu32*)arg = TRUE; 83}</CODE></PRE> 84</BLOCKQUOTE> 85<H3><br> DMA Controller Bugs</H3> 86<P>The old DMAC exposed a hardware bug. With multiple DMAs and varying conditions, illegal read access results if the source address of DMA0 is of the form 0xmmnnnnnn (where 0xmm = 0x04 or 0x08 through 0xff, and nnnnnn = anything). The same restriction applies to the source address after the transfer is complete. For this reason, if the source address or source address when transfer terminates fall within this address range, execution stops on an <CODE><A href="../../os/debug/OS_Panic.html">OS_Panic</A></CODE> function inside the library.</P> 87<P>With the TWL, however, you can select to correct the problem with the old DMA circuit by using the <CODE><A href="../../scfg/scfg/SCFG_SetDmacFixed.html">SCFG_SetDmaFixed</A></CODE> function. No address check is performed if you select to correct the problem.</P> 88<H2>Internal Operation</H2> 89<P>Uses the following IO registers: DMA<i>n</i> source register (0x40000B0 + 12<i>n</i>), DMA<i>n</i> destination register (0x40000B4 + 12<i>n</i>), and DMA<i>n</i> control register (0x40000B8 + 12<i>n</i>). (<i>n</i> is the DMA channel used.))</P> 90<H2>See Also</H2> 91<P><A href="../memory/MI_CpuCopy.html"><CODE>MI_CpuCopy*</CODE></A><BR> <A href="MI_DmaClear.html"><CODE>MI_DmaClear*</CODE></A><BR> <A href="MI_DmaFill.html"><CODE>MI_DmaFill*</CODE></A><BR> <A href="MI_DmaRestart.html"><CODE>MI_DmaRestart</CODE></A><BR> <A href="MI_DmaSend.html"><CODE>MI_DmaSend*</CODE></A></P> 92<H2>Revision History</H2> 93<P>2009/11/20 Added a description of a bug in the DMA controller.<BR>2007/10/31 Added <CODE>_SetUp()</CODE>.<BR>2005/03/08 Standardized the notation used for the term "interrupt" in Japanese.<BR>2004/12/22 Added a description of calling the callback.<BR>2005/03/08 Initial version.</P> 94<hr><p>CONFIDENTIAL</p></body> 95</HTML>