在线咨询
eetop公众号 创芯大讲堂 创芯人才网
切换到宽版

EETOP 创芯网论坛 (原名:电子顶级开发网)

手机号码,快捷登录

手机号码,快捷登录

找回密码

  登录   注册  

快捷导航
搜帖子
查看: 2725|回复: 1

[求助] NIOS DMA调试问题,请教大侠指导一下,谢谢

[复制链接]
发表于 2014-5-27 19:18:34 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有账号?注册

x
在调试NIOS 两个onchip_memery  DMA传输时,传输的数据只有部分对,好像是有规律,找了很多资料,还是没找到问题,新手。谢谢
附代码如下:
#include <stdio.h>
        #include <string.h>
        #include <alt_types.h>
        #include "system.h"
        #include "sys/alt_dma.h"
        #include "unistd.h"

        #include "io.h"
        #include <sys/alt_cache.h>

        static volatile int tx_done = 0;
        //回调函数

        static void done (void* handle)
        {
        tx_done++;
        }
        //#define TRANSFER_LENGTH 32
        const int TRANSFER_LENGTH =16 ;
        int main(void)
        {
                 int data[TRANSFER_LENGTH] ;
//#pragma DATA_SECTION (data,".ONCHIP_RAM0_BASE");
        int i=0;
        for(i=0;i<TRANSFER_LENGTH;i++)
                data=i+100;
            int *source = ( int*)(data);
            int *dest   = ( int*)(ONCHIP_RAM1_BASE);
            //memset(source,0x55,TRANSFER_LENGTH*sizeof(char));

            alt_dma_txchan tx;
            //创建DMA发送信道
            tx = alt_dma_txchan_open("/dev/dma0");
            //当信道创建成功
            if(tx == NULL)
            {
                printf("Failed to open transit channel.\n");
            }
            else
            {
                printf("Create the transit channel successfully.\n");
            }

            //创建DMA接收通道
            alt_dma_rxchan  rx;
            rx = alt_dma_rxchan_open("/dev/dma0");
            //当信道创建成功
             if(rx == NULL)
            {
                printf("Failed to open receive channel.\n");
            }
            else
            {
                printf("Create the receive channel successfully.\n");
            }

        //     alt_dma_txchan_ioctl(tx,ALT_DMA_SET_MODE_32 ,NULL);
             if(alt_dma_txchan_send(tx,
                                    source,
                                    TRANSFER_LENGTH,
                                    NULL,
                                    NULL)<0)
                {
                printf ("Error: failed to post transmit request\n");
                }
             else
                     printf ("ok: success to post transmit request\n");

            //提交DMA接收请求指定接收数据的位置(sdram)以及传输数据量
//             cwg = alt_dma_txchan_ioctl(rx,ALT_DMA_SET_MODE_8 ,NULL);
         //    alt_dma_rxchan_ioctl(rx,ALT_DMA_SET_MODE_32 ,NULL);
            if(alt_dma_rxchan_prepare(rx,
                                      dest,
                                    TRANSFER_LENGTH,
                                      done,
                                      NULL) < 0)
                {
                printf ("Error: failed to post receive request\n");
                }
            else
                    printf ("ok: success to post receive request\n");
        // 等待发送结束
        while (!tx_done);

        printf("Transmit successful\n");

        usleep(5000000);
        int loop,errorcount=0;
        for(loop=1;loop<TRANSFER_LENGTH;loop++)
        {
            //对比缓冲区数据
            if(source[loop]!=dest[loop])
            {
                printf("Verify failed at location: %d\n",loop);
                errorcount++;
            }
        }
        if(errorcount==0)
        {
            printf("Transfer successfully !\n");
        }
        else
        {
            printf("Transfer failed !\n");
        }

for(i=0;i<TRANSFER_LENGTH;i++)
        printf("dest[%d]:  %d\n",i,*(dest+i));

   return(0);
//        while(1);
        }

////////////////////////////////////////////////////运行结果如下
Create the transit channel successfully.
Create the receive channel successfully.
ok: success to post transmit request
ok: success to post receive request
Transmit successful
Verify failed at location: 8
Verify failed at location: 9
Verify failed at location: 10
Verify failed at location: 11
Verify failed at location: 12
Verify failed at location: 13
Verify failed at location: 14
Verify failed at location: 15
Transfer failed !
dest[0]:  100
dest[1]:  101
dest[2]:  102
dest[3]:  103
dest[4]:  104
dest[5]:  105
dest[6]:  106
dest[7]:  107
dest[8]:  0
dest[9]:  0
dest[10]:  0
dest[11]:  0
dest[12]:  0
dest[13]:  0
dest[14]:  0
dest[15]:  0

QSYS.rar

198.15 KB, 下载次数: 7 , 下载积分: 资产 -2 信元, 下载支出 2 信元

 楼主| 发表于 2014-5-29 11:23:55 | 显示全部楼层
求助哪位大侠帮忙看一下啊,毕设紧急!谢谢
您需要登录后才可以回帖 登录 | 注册

本版积分规则

关闭

站长推荐 上一条 /2 下一条

×

小黑屋| 关于我们| 联系我们| 在线咨询| 隐私声明| EETOP 创芯网
( 京ICP备:10050787号 京公网安备:11010502037710 )

GMT+8, 2024-4-28 12:52 , Processed in 0.025081 second(s), 10 queries , Gzip On, Redis On.

eetop公众号 创芯大讲堂 创芯人才网
快速回复 返回顶部 返回列表