我的程序是从软件参考手册中复制过来修改的,两个数组均放在了SDRAM中,DMA启动运行都没问题,只是传输过后,看内存中的数据有问题,有的地方并没有复制过去,请问这是什么原因呢?
程序代码如下:
BYTE strR[1024];
volatile BYTE strW[1024];
static volatile int rx_done = 0;
/*
* Callback function that obtains notification that the data has
* been received.
*/
static void done (void* handle, void* data)
{
rx_done++;
}
void InitDMA()
{
DWORD st;
for(int i=0;i<512;i++)
{
strR=i&0xff;
strW=0;
}
int rc;
alt_dma_txchan txchan;
alt_dma_rxchan rxchan;
void* tx_data = (void*) strR; /* pointer to data to send */
void* rx_buffer = (void*) strW; /* pointer to rx buffer */
/* Create the transmit channel */
if ((txchan = alt_dma_txchan_open("/dev/dma")) == NULL)
{
printf ("Failed to open transmit channel\r\n");
exit (1);
}
/* Create the receive channel */
if ((rxchan = alt_dma_rxchan_open("/dev/dma")) == NULL)
{
printf ("Failed to open receive channel\r\n");
exit (1);
}
/* Post the transmit request */
if ((rc = alt_dma_txchan_send (txchan,
tx_data,
1024,
NULL,
NULL)) < 0)
{
printf ("Failed to post transmit request, reason = %i\r\n", rc);
exit (1);
}
/* Post the receive request */
if ((rc = alt_dma_rxchan_prepare (rxchan,
rx_buffer,
1024,
done,
NULL)) < 0)
{
printf ("Failed to post read request, reason = %i\r\n", rc);
exit (1);
}
/* wait for transfer to complete */
while (!rx_done);
printf ("Transfer successful!\r\n");
ShowData(strR,512);
TRACE("strWP=%p\r\n",strW);
ShowData((PUINT8)strW,512);
}
终端上显示的内容:
0000: 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F ................
0010: 10 11 12 13 14 15 16 17 18 19 1A 1B 1C 1D 1E 1F ................
0020: 20 21 22 23 24 25 26 27 28 29 2A 2B 2C 2D 2E 2F !"#$%&'()*+,-./
0030: 30 31 32 33 34 35 36 37 38 39 3A 3B 3C 3D 3E 3F 0123456789:;<=>?
0040: 40 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F @ABCDEFGHIJKLMNO
0050: 50 51 52 53 54 55 56 57 58 59 5A 5B 5C 5D 5E 5F PQRSTUVWXYZ[\]^_
0060: 60 61 62 63 64 65 66 67 68 69 6A 6B 6C 6D 6E 6F `abcdefghijklmno
0070: 70 71 72 73 74 75 76 77 78 79 7A 7B 7C 7D 7E 7F pqrstuvwxyz{|}~.
0080: 80 81 82 83 84 85 86 87 88 89 8A 8B 8C 8D 8E 8F ................
0090: 90 91 92 93 94 95 96 97 98 99 9A 9B 9C 9D 9E 9F ................
00A0: A0 A1 A2 A3 A4 A5 A6 A7 A8 A9 AA AB AC AD AE AF ................
00B0: B0 B1 B2 B3 B4 B5 B6 B7 B8 B9 BA BB BC BD BE BF ................
00C0: C0 C1 C2 C3 C4 C5 C6 C7 C8 C9 CA CB CC CD CE CF ................
00D0: D0 D1 D2 D3 D4 D5 D6 D7 D8 D9 DA DB DC DD DE DF ................
00E0: E0 E1 E2 E3 E4 E5 E6 E7 E8 E9 EA EB EC ED EE EF ................
00F0: F0 F1 F2 F3 F4 F5 F6 F7 F8 F9 FA FB FC FD FE FF ................
0100: 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F ................
0110: 10 11 12 13 14 15 16 17 18 19 1A 1B 1C 1D 1E 1F ................
0120: 20 21 22 23 24 25 26 27 28 29 2A 2B 2C 2D 2E 2F !"#$%&'()*+,-./
0130: 30 31 32 33 34 35 36 37 38 39 3A 3B 3C 3D 3E 3F 0123456789:;<=>?
0140: 40 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F @ABCDEFGHIJKLMNO
0150: 50 51 52 53 54 55 56 57 58 59 5A 5B 5C 5D 5E 5F PQRSTUVWXYZ[\]^_
0160: 60 61 62 63 64 65 66 67 68 69 6A 6B 6C 6D 6E 6F `abcdefghijklmno
0170: 70 71 72 73 74 75 76 77 78 79 7A 7B 7C 7D 7E 7F pqrstuvwxyz{|}~.
0180: 80 81 82 83 84 85 86 87 88 89 8A 8B 8C 8D 8E 8F ................
0190: 90 91 92 93 94 95 96 97 98 99 9A 9B 9C 9D 9E 9F ................
01A0: A0 A1 A2 A3 A4 A5 A6 A7 A8 A9 AA AB AC AD AE AF ................
01B0: B0 B1 B2 B3 B4 B5 B6 B7 B8 B9 BA BB BC BD BE BF ................
01C0: C0 C1 C2 C3 C4 C5 C6 C7 C8 C9 CA CB CC CD CE CF ................
01D0: D0 D1 D2 D3 D4 D5 D6 D7 D8 D9 DA DB DC DD DE DF ................
01E0: E0 E1 E2 E3 E4 E5 E6 E7 E8 E9 EA EB EC ED EE EF ................
01F0: F0 F1 F2 F3 F4 F5 F6 F7 F8 F9 FA FB FC FD FE FF ................
strWP=0x2047824
0000: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
0010: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
0020: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
0030: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
0040: 40 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F @ABCDEFGHIJKLMNO
0050: 50 51 52 53 54 55 56 57 58 59 5A 5B 5C 5D 5E 5F PQRSTUVWXYZ[\]^_
0060: 60 61 62 63 64 65 66 67 68 69 6A 6B 6C 6D 6E 6F `abcdefghijklmno
0070: 70 71 72 73 74 75 76 77 78 79 7A 7B 7C 7D 7E 7F pqrstuvwxyz{|}~.
0080: 80 81 82 83 84 85 86 87 88 89 8A 8B 8C 8D 8E 8F ................
0090: 90 91 92 93 94 95 96 97 98 99 9A 9B 9C 9D 9E 9F ................
00A0: A0 A1 A2 A3 A4 A5 A6 A7 A8 A9 AA AB AC AD AE AF ................
00B0: B0 B1 B2 B3 B4 B5 B6 B7 B8 B9 BA BB BC BD BE BF ................
00C0: C0 C1 C2 C3 C4 C5 C6 C7 C8 C9 CA CB 00 00 00 00 ................
00D0: D0 D1 D2 D3 D4 D5 D6 D7 D8 D9 DA DB DC DD DE DF ................
00E0: E0 E1 E2 E3 00 00 00 00 00 00 00 00 EC ED EE EF ................
00F0: F0 F1 F2 F3 F4 F5 F6 F7 00 00 00 00 FC FD FE FF ................
0100: 00 00 00 00 00 00 00 00 08 09 0A 0B 00 00 00 00 ................
0110: 10 11 12 13 00 00 00 00 18 19 1A 1B 00 00 00 00 ................
0120: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
0130: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
0140: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
0150: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
0160: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
0170: 00 00 00 00 74 75 76 77 78 79 7A 7B 7C 7D 7E 7F ....tuvwxyz{|}~.
0180: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
0190: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
01A0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
01B0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
01C0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
01D0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
01E0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
01F0: F0 F1 F2 F3 00 00 00 00 F8 F9 FA FB 00 00 00 00 ................
欢迎光临 电子技术论坛_中国专业的电子工程师学习交流社区-中电网技术论坛 (http://bbs.eccn.com/) | Powered by Discuz! 7.0.0 |