完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
最近在做srio数据传输的驱动,选择的是direct I/O NWRITE 事务,tms320c6457 dspji将其tx0链接到rx0构成serdes回环。我在数据文档以及其他参考资料中看到srio的lsu一次写操作(nwrite)最多可以发送4096个字节,也就是byte_count的值可以是256,最大是4096.如果要一次发送5000个字节,该如何对分包操作进行编程呢?我用的方法是先将要发送的数组的元素的个数与byte_count做比较,然后利用for循环,将数据分成两个大包,单步调试的时候,数据能够正确发送,但是只要一全速运行,不管发送的数据是多少(10,100,1000,4096,5000或者10000)接受到的数据都会发生错误,有时还会一直running,想请ti工程师帮忙看下程序哪里出了错误!红色字体部分是我改的地方。。。假设发送5000个字节,则数组大小应为2500.恳请各位大神帮忙了,谢谢! #include #include #include #include #include /*********************************************************************** ************************** LOCAL Definitions ************************** ***********************************************************************/ /* Device Identifiers (8bit and 16bit) for the Source Application. */ #define LARGE_DEV_ID 0xBEEF #define SMALL_DEV_ID 0xAB /* RIO NWrite Command Identifier. */ #define SRIO_PKT_TYPE_NWRITE 0x54 /* SRIO Port Number which is being used. */ #define SRIO_PORT_NUMBER 0 /* Length of data being transferred. */ #define TRANESFER_SIZE 4096 /************************************************************************ ************************** GLOBAL Definitions ************************** ************************************************************************/ /* Global Source and Destination buffers. */ static Uint16 src[shuzudaxiao]; static Uint16 dst[shuzudaxiao]; /* Global SRIO Hardware Setup is used */ static CSL_SrioHwSetup setup = CSL_SRIO_HWSETUP_DEFAULTS; /************************************************************************ ************************** LSU Example Functions *********************** ************************************************************************/ /* * ============================================================================ * @Func delay * * @desc * This routine is used to spin in a delay loop for delay iterations * ============================================================================ */ static void delay(Uint32 delay) { volatile Uint32 i, n; n = 0; for (i = 0; i < delay; i++) { n = n + 1; } } void main (void) { volatile Uint32 index; volatile Uint32 zijieshu,shang,yushu,baogeshu,i; CSL_SrioContext context; CSL_Status status; CSL_SrioHandle hSrio; CSL_SrioObj srioObj; CSL_SrioParam srioParam; CSL_SrioDirectIO_ConfigXfr lsu_conf = {0}; CSL_SrioPortData response; CSL_SrioCntlSym cntrlSym; CSL_SrioLsuCompStat completionCode; /* Enable SRIO in PSC control module */ enableSRIO(); /* Initialization and Open of the SRIO */ status = CSL_srioInit (&context); hSrio = CSL_srioOpen (&srioObj, 0, &srioParam, &status); if (status != CSL_SOK) { printf("SRIO: ... Cannot open SRIO, failedn"); return; } /* Create the setup structure */ srio_Create_Setup (&setup); /* Setup the SRIO with the selected setup in the last step */ status = CSL_srioHwSetup (hSrio, &setup); if (status != CSL_SOK) { printf("SRIO: ... Hardware setup, failedn"); return; } /* Setup the source and destination */ for(index=0; index src[index] = index ; dst[index] = 0; } /* Make sure that the SRIO Port is Initialized. */ printf ("Debug: Waiting for SRIO Port %d to be initializedn", SRIO_PORT_NUMBER); /* Loop around till the PORT is initialized. */ response.index = SRIO_PORT_NUMBER; do { delay(10000); //check the response every 100 cpu clcok = 100 ns CSL_srioGetHwStatus (hSrio, CSL_SRIO_QUERY_SP_ERR_STAT, &response); }while(response.data & 0x1); /* Clear any errors... */ cntrlSym.portNum = (CSL_SrioPortNum)SRIO_PORT_NUMBER; cntrlSym.stype0 = 0x2; cntrlSym.par0 = 0x0; cntrlSym.par1 = 0x1F; cntrlSym.stype1 = 0x4; cntrlSym.cmd = 0x4; cntrlSym.emb = 0x0; CSL_srioHwControl (hSrio, CSL_SRIO_CMD_CNTL_SYM_SET, &cntrlSym); /* Read the Port Error Status register. */ response.index = SRIO_PORT_NUMBER; CSL_srioGetHwStatus (hSrio, CSL_SRIO_QUERY_SP_ERR_STAT, &response); /* Was there an error detected? */ if ((response.data & ~0x2) != 0) { /* Error was detected; we need to clear this before we can proceed... */ printf ("Error: Port %d has Input/Output Error... clearingn", SRIO_PORT_NUMBER); /* Clearing the errors... */ CSL_srioHwControl (hSrio, CSL_SRIO_CMD_SP_ERR_STAT_CLEAR, &response); } zijieshu=shuzudaxiao*2; shang=zijieshu/TRANESFER_SIZE; yushu=zijieshu%TRANESFER_SIZE; if(TRANESFER_SIZE<=zijieshu) { if(shang==0) baogeshu=shang; else baogeshu=shang+1; for(i=1;i<=baogeshu;i++) { /*********************************************************************************** ********************************* DATA Transfer *********************************** ***********************************************************************************/ /* Create an LSU configuration */ lsu_conf.srcNodeAddr = (Uint32)&src[0+2048(i-1)]; /* Source address */ lsu_conf.dstNodeAddr.addressHi = 0; lsu_conf.dstNodeAddr.addressLo = (Uint32)&dst[0+2048(i-1)] /* Destination address */ lsu_conf.byteCnt = TRANSFER_SIZE; /* Size of data */ lsu_conf.idSize = 1; /* 16 bit device id */ lsu_conf.priority = 2; /* PKT priority is 2 */ lsu_conf.xambs = 0; /* Not an extended address */ lsu_conf.dstId = LARGE_DEV_ID; /* Destination ID */ lsu_conf.intrReq = 0; /* No interrupts */ lsu_conf.pktType = SRIO_PKT_TYPE_NWRITE;/* Write with no response */ lsu_conf.hopCount = 0; /* Valid for maintainance pkt */ lsu_conf.doorbellInfo = 0; /* Not a doorbell pkt */ lsu_conf.outPortId = SRIO_PORT_NUMBER; /* Tx on specified SRIO Port */ /* Configure the LSU and start transmission */ CSL_srioLsuSetup (hSrio, &lsu_conf, 0); } } /* Wait for the completion of transfer */ response.index = 0; while (1) { /* Poll and check if the LSU has completed */ CSL_srioGetHwStatus (hSrio, CSL_SRIO_QUERY_LSU_BSY_STAT, &response); /* Is the LSU not busy */ if (response.data == 0) break; } /* Get the completion Code for the specific LSU. */ completionCode.portNum = CSL_SRIO_PORT_0; CSL_srioLsuCompCodeStat(hSrio, &completionCode); if (completionCode.lsuCompCode != 0x0) { /* Failed Transfer. */ printf ("Error: SRIO Write has a completion code of %dn", completionCode.lsuCompCode); return; } printf ("Debug: SRIO Transfer was completed; validating...n"); /* Validate the received data to ensure data was transferred correctly. */ for(index=0; index if (src[index] != dst[index]) break; } if (index == shuzudaxiao) printf("Debug: Data Transfer Validatedn"); else printf("Error: Data Transfer Corruptedn"); } |
|
相关推荐
|
|
你正在撰写答案
如果你是对答案或其他答案精选点评或询问,请使用“评论”功能。
593 浏览 0 评论
基于 DSP5509 进行数字图像处理中 Sobel 算子边缘检测的硬件连接电路图
3410 浏览 0 评论
814 浏览 0 评论
普中科技F28335开发板中,如何使用aic23播放由代码生成的正弦波
3830 浏览 0 评论
4588 浏览 1 评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-12-29 07:57 , Processed in 0.639248 second(s), Total 71, Slave 54 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号