NIOS2 DMA Memory to Memory Transfer
2011-04-06 13:53
211 查看
http://blog.ednchina.com/chactor/185802/message.aspx
#include <stdio.h>
#include <stdlib.h>
#include <sys/alt_dma.h>
#include "system.h"
static volatile int rx_done = 0;
int rc;
alt_dma_txchan txchan;
alt_dma_rxchan rxchan;
static char buff[256]; /* 待传数据 */
void* tx_data = (void*) buff; /* 源地址 */
void* rx_buffer = (void*) ONCHIP_MEMORY_BASE; /* 目标地址*/
//DMA传输结束回调函数
static void done_t(void* handle, void* data)
{
rx_done++;
}
int main (void)
{
/* 打开发送通道 */
if ((txchan = alt_dma_txchan_open("/dev/dma_1")) == NULL)
{
printf ("Failed to open transmit channel\n");
exit (1);
}
else
printf("打开发送通道.\n");
/* 打开接收通道 */
if ((rxchan = alt_dma_rxchan_open("/dev/dma_1")) == NULL)
{
printf ("Failed to open receive channel\n");
exit (1);
}
else
printf("打开接收通道.\n");
/* 开始发送数据 */
if ((rc = alt_dma_txchan_send (txchan,
tx_data,
128,
NULL,
NULL)) < 0)
{
printf ("Failed to post transmit request, reason = %i\n", rc);
exit (1);
}
else
printf("开始发送数据.\n");
/* 开始接收数据*/
if ((rc = alt_dma_rxchan_prepare (rxchan,
rx_buffer,
128,
done_t,
NULL)) < 0)
{
printf ("Failed to post read request, reason = %i\n", rc);
exit (1);
}
else
printf("开始接收数据.\n");
/* 等待传输结束 */
while (!rx_done);
printf ("Transfer successful!\n");
return 0;
}
不是很理解回调函数,代码是参照EDN那个前辈的,先测试,目前没时间求甚解
(1)DMA长度寄存器设为8 bit了, Onchip_Menory Data_Width为32位了,怎么可以传输的好好的???
#include <stdio.h>
#include <stdlib.h>
#include <sys/alt_dma.h>
#include "system.h"
static volatile int rx_done = 0;
int rc;
alt_dma_txchan txchan;
alt_dma_rxchan rxchan;
static char buff[256]; /* 待传数据 */
void* tx_data = (void*) buff; /* 源地址 */
void* rx_buffer = (void*) ONCHIP_MEMORY_BASE; /* 目标地址*/
//DMA传输结束回调函数
static void done_t(void* handle, void* data)
{
rx_done++;
}
int main (void)
{
/* 打开发送通道 */
if ((txchan = alt_dma_txchan_open("/dev/dma_1")) == NULL)
{
printf ("Failed to open transmit channel\n");
exit (1);
}
else
printf("打开发送通道.\n");
/* 打开接收通道 */
if ((rxchan = alt_dma_rxchan_open("/dev/dma_1")) == NULL)
{
printf ("Failed to open receive channel\n");
exit (1);
}
else
printf("打开接收通道.\n");
/* 开始发送数据 */
if ((rc = alt_dma_txchan_send (txchan,
tx_data,
128,
NULL,
NULL)) < 0)
{
printf ("Failed to post transmit request, reason = %i\n", rc);
exit (1);
}
else
printf("开始发送数据.\n");
/* 开始接收数据*/
if ((rc = alt_dma_rxchan_prepare (rxchan,
rx_buffer,
128,
done_t,
NULL)) < 0)
{
printf ("Failed to post read request, reason = %i\n", rc);
exit (1);
}
else
printf("开始接收数据.\n");
/* 等待传输结束 */
while (!rx_done);
printf ("Transfer successful!\n");
return 0;
}
不是很理解回调函数,代码是参照EDN那个前辈的,先测试,目前没时间求甚解
(1)DMA长度寄存器设为8 bit了, Onchip_Menory Data_Width为32位了,怎么可以传输的好好的???
相关文章推荐
- NIOS2 DMA Memory to Peripheral Trnasfer
- Timer-triggered memory-to-memory DMA transfer demonstrator
- 【stm32f103】DMA应用memory to memory(寄存器版)
- 【转载】Nios II DMA: memory to memory
- DMA : Timer Trigger Memory-to-memory mode,
- Data transfer from GPIO port to RAM buffer using DMA upon receiving a trigger signal on the timer capture input channel.
- zedboard平台下DMA实现memory to memory传输
- :"ORA-27121: unable to determine size of shared memory segment" 错误
- Android 启动模拟器是出现“Failed to allocate memory: 8”错误提示的原因及解决办法
- Android 启动模拟器是出现“Failed to allocate memory: 8”错误提示的原因及解决办法
- 解决 - java.lang.OutOfMemoryError: unable to create new native thread
- AppDomain is marked for unload due to memory pressure.
- 【论文笔记】Person Transfer GAN to Bridge Domain Gap for Person Re-Identification
- Spark - ERROR Executor: java.lang.OutOfMemoryError: unable to create new native thread
- ArtifactTransferException: Failure to transfer org.apache.openejb:javaee-api:jar:5.0-1
- How To Debug Memory Leaks with XCode and Instruments Tutorial 边读边记
- Maven error “Failure to transfer…”解决办法
- When is a Leak not a Leak? Using Heapshot Analysis to Find Undesirable Memory Growth
- OutOfMemoryError: unable to create new native t...
- C++ AMP: Any optimization ways in memory transfer in AMP?