使用了两个通道,channel0和channel8,通道0的数据只能传四分之一就停止了,通道8因此也就不能接着传数据
以下是自己改的程序,不知道哪里错了,interrupt enable 那里有点不太清楚,使能的事件数有什么特别的要求吗?
刚开始学6678,有很多不会的地方,求指教
#include <stdio.h>
#include <ti/csl/csl_edma3.h>
#include <ti/csl/csl_edma3Aux.h>
#include <ti/csl/csl_cacheAux.h>
/**********************************************************************
************************** Global Variables **************************
**********************************************************************/
/* Global Variables which are used to dump the TPCC register overlay in the * debugger… */ //其中CSL_TpccRegs就是指EDMA control register 包含的所有寄存器, three EDMA in total
CSL_TpccRegs* gEDMACC0Regs = (CSL_TpccRegs*)CSL_EDMA0CC_REGS;//#define CSL_EDMA0CC_REGS (0x02700000)
CSL_TpccRegs* gEDMACC1Regs = (CSL_TpccRegs*)CSL_EDMA1CC_REGS;//#define CSL_EDMA1CC_REGS (0x02720000)
CSL_TpccRegs* gEDMACC2Regs = (CSL_TpccRegs*)CSL_EDMA2CC_REGS;//#define CSL_EDMA2CC_REGS (0x02740000)
/* Global Buffers (Source and Destination) for PING-PONG */
float srcBuff1[512];
float srcBuff2[512];
float dstBuff1[512];
float dstBuff2[512];
/**********************************************************************
************************ EDMA TEST FUNCTIONS *************************
**********************************************************************/
/*
* =============================================================================
* @func edma_chain_example
*
* @arg
* NONE
*
* @desc
* This is the example routine which perform edma interrupt.
* It implements following steps
* 1. Intializes and Opens the Edma
* 2. Sets up the edma module using the API csl_edma3Hwsetup ()
* 4. Enables the edma region5 using CSL_EDMA3_CMD_DMAREGION_ENABLE.
* 5. Opens the channel 0 and get the param handle.
* 6. Sets up the edma param entry for channel 0
* 7. Opens the channel 8 and get the param handle.
* 8. Sets up the edma param entry for channel 8
* 9. Enables the channels using CSL_EDMA3_CMD_CHANNEL_ENABLE
* 10. Manually trigger the channel 0 using CSL_EDMA3_CMD_CHANNEL_SET.//channel 0 trigger channel8 later
* 10. Waits for transfer to complete.
* 11. Compares the data in the destination buffer is proper or not.
* 12. Closes the edma module and channel.
*
* @return
* NONE
*不更新param set表,每个通道只有一个param set;ie:channel0–param set0;channel8–param set8
* ===================================================================================
*/
void edma_chain_xfer_region (Int32 instNum, Uint8 channelNum1,Uint8 channelNum2, Int32 regionNum,float *srcBuff1,float *dstBuff1,float *srcBuff2,float *dstBuff2)
{
CSL_Edma3Handle hModule;
CSL_Edma3Obj edmaObj;
CSL_Edma3ParamHandle hParamBasic;
CSL_Edma3ParamHandle hParamBasic1;
CSL_Edma3ChannelObj chObj,chObj1;
CSL_Edma3CmdIntr regionIntr;
CSL_Edma3CmdDrae regionAccess;
CSL_Edma3ChannelHandle hChannel,hChannel1;
CSL_Edma3ParamSetup myParamSetup,myParamSetup1;
CSL_Edma3Context context;
CSL_Edma3ChannelAttr chAttr,chAttr1;
CSL_Status status;
/* Module Initialization */
if (CSL_edma3Init(&context) != CSL_SOK) {
printf ("Error: EDMA module initialization failed\n");
}
/* Module level open */
hModule = CSL_edma3Open(&edmaObj, instNum, NULL, &status);
if ((hModule == NULL) || (status != CSL_SOK))
{
printf ("Error: EDMA module open failed\n");
}
/* Determine the number of channels we need to enable. Is this Instance 0? */
if (instNum == 0)
{
/* YES. DRAE enable(Bits 0-15) for the shadow region; since there are 16 channels. */
regionAccess.region = regionNum;
regionAccess.drae = 0xFFFF;
regionAccess.draeh = 0x0;
if (CSL_edma3HwControl(hModule,CSL_EDMA3_CMD_DMAREGION_ENABLE, ®ionAccess) != CSL_SOK)
{
printf ("Error: EDMA region enable command failed\n");
}
}
else
{
/* YES. DRAE enable(Bits 0-63) for the shadow region; since there are 64 channels. */
regionAccess.region = regionNum;
regionAccess.drae = 0xFFFFFFFF;
regionAccess.draeh = 0xFFFFFFFF;
if (CSL_edma3HwControl(hModule,CSL_EDMA3_CMD_DMAREGION_ENABLE, ®ionAccess) != CSL_SOK)
{
printf ("Error: EDMA region enable command failed\n");
} }
/* Interrupt enable (Bits 0-11) for the shadow region 5*/
regionIntr.region = regionNum;
regionIntr.intr = 0x0FFF;
regionIntr.intrh = 0x0000;
if (CSL_edma3HwControl(hModule,CSL_EDMA3_CMD_INTR_ENABLE, ®ionIntr) != CSL_SOK)
{
printf ("Error: EDMA interrupts enable command failed\n");
}
/* Channel0 open in context of shadow region 5 */
chAttr.regionNum = regionNum;
chAttr.chaNum = channelNum1;
hChannel = CSL_edma3ChannelOpen(&chObj, instNum, &chAttr, &status); if ((hChannel == NULL) || (status != CSL_SOK))
{
printf ("Error: EDMA channel open failed\n");
}
CSL_edma3HwChannelSetupParam(hChannel, channelNum1);
if (status != CSL_SOK) {
printf ("Edma channel setup param failed\n");
}
/* Change Channel Default queue setup to 0 */
status = CSL_edma3HwChannelSetupQue(hChannel,CSL_EDMA3_QUE_0);
if (status != CSL_SOK) {
printf ("Edma channel setup que failed\n");
}
/* Obtain a handle to parameter set 0 */
hParamBasic = CSL_edma3GetParamHandle(hChannel,0,&status);
if (hParamBasic == NULL) {
printf ("Edma get param handle for param entry 0 failed\n");
}
/* Setup the param set */
myParamSetup.option = CSL_EDMA3_OPT_MAKE( CSL_EDMA3_ITCCH_DIS, \
CSL_EDMA3_TCCH_EN, \
CSL_EDMA3_ITCINT_DIS, \
CSL_EDMA3_TCINT_EN,\
0,CSL_EDMA3_TCC_NORMAL,\
CSL_EDMA3_FIFOWIDTH_NONE, \
CSL_EDMA3_STATIC_EN, \
CSL_EDMA3_SYNC_A, \
CSL_EDMA3_ADDRMODE_INCR, \
CSL_EDMA3_ADDRMODE_INCR
);
myParamSetup.srcAddr = (Uint32)srcBuff1;
myParamSetup.aCntbCnt = CSL_EDMA3_CNT_MAKE(512,1);
myParamSetup.dstAddr = (Uint32)dstBuff1;
myParamSetup.srcDstBidx = CSL_EDMA3_BIDX_MAKE(1,1);
myParamSetup.linkBcntrld = CSL_EDMA3_LINKBCNTRLD_MAKE(CSL_EDMA3_LINK_NULL,1);
myParamSetup.srcDstCidx = CSL_EDMA3_CIDX_MAKE(0,1);
myParamSetup.cCnt = 1;
status = CSL_edma3ParamSetup(hParamBasic, &myParamSetup);
if (status != CSL_SOK) {
printf("Edma parameter entry 0 setup is failed\n");
}
/* Channel 8 open in context of shadow region 5 */
chAttr1.regionNum = CSL_EDMA3_REGION_5;
chAttr1.chaNum = channelNum2;
hChannel1 = CSL_edma3ChannelOpen(&chObj1, instNum, &chAttr1, &status);
if ((hChannel1 == NULL) || (status != CSL_SOK)) {
printf ("Edma channel open failed\n");
}
CSL_edma3HwChannelSetupParam(hChannel1, channelNum2);
if (status != CSL_SOK) {
printf ("Edma channel setup param failed\n");
}
/* Change Channel Default queue setup to 0 */
status = CSL_edma3HwChannelSetupQue(hChannel1,CSL_EDMA3_QUE_0);
if (status != CSL_SOK) {
printf ("Edma channel setup que failed\n");
}
/* Obtain a handle to parameter set 8 */
hParamBasic1 = CSL_edma3GetParamHandle(hChannel1,8,&status);
/* Setup the param set */
myParamSetup1.option = CSL_EDMA3_OPT_MAKE( CSL_EDMA3_ITCCH_DIS, \
CSL_EDMA3_TCCH_EN, \
CSL_EDMA3_ITCINT_DIS, \
CSL_EDMA3_TCINT_EN,\
1,CSL_EDMA3_TCC_NORMAL,\
CSL_EDMA3_FIFOWIDTH_NONE, \
CSL_EDMA3_STATIC_EN, \
CSL_EDMA3_SYNC_A, \
CSL_EDMA3_ADDRMODE_INCR, \
CSL_EDMA3_ADDRMODE_INCR
);
myParamSetup1.srcAddr = (Uint32)srcBuff2;
myParamSetup1.aCntbCnt = CSL_EDMA3_CNT_MAKE(512,1);
myParamSetup1.dstAddr = (Uint32)dstBuff2;
myParamSetup1.srcDstBidx = CSL_EDMA3_BIDX_MAKE(1,1);
myParamSetup1.linkBcntrld = CSL_EDMA3_LINKBCNTRLD_MAKE(CSL_EDMA3_LINK_NULL,1);
myParamSetup1.srcDstCidx = CSL_EDMA3_CIDX_MAKE(0,1);
myParamSetup1.cCnt = 1;
status = CSL_edma3ParamSetup(hParamBasic1,&myParamSetup1);
if (status != CSL_SOK) {
printf("Edma parameter entry 1 setup is failed\n");
}
/* Enable channel 0 */
status = CSL_edma3HwChannelControl(hChannel,CSL_EDMA3_CMD_CHANNEL_ENABLE, NULL);
if (status != CSL_SOK) {
printf("Edma channel enable command for channel 0 is failed\n");
}
/* Enable channel 8 */
status = CSL_edma3HwChannelControl(hChannel1,CSL_EDMA3_CMD_CHANNEL_ENABLE, \
NULL);
if (status != CSL_SOK) {
printf("Edma channel enable command for channel 8 is failed\n");
}
/* Initialize data
for (loopIndex = 0; loopIndex < 512; loopIndex++) {
srcBuff1[loopIndex] = loopIndex;
srcBuff2[loopIndex] = loopIndex;
dstBuff1[loopIndex] = 0;
dstBuff2[loopIndex] = 0;
}
*/
/* Manually trigger the channel 0 */
if (CSL_edma3HwChannelControl(hChannel,CSL_EDMA3_CMD_CHANNEL_SET,NULL) != CSL_SOK)
{
printf("Error: EDMA channel set command is failed\n");
}
regionIntr.region = regionNum;
// regionIntr.intr = 0;
// regionIntr.intrh = 0;
/* Poll on interrupt pend bit 1 */
do {
CSL_edma3GetHwStatus(hModule,CSL_EDMA3_QUERY_INTRPEND,®ionIntr);
} while (!(regionIntr.intr & 0x2));
/* Clear interrupt bit 1 */
if (CSL_edma3HwControl(hModule,CSL_EDMA3_CMD_INTRPEND_CLEAR, ®ionIntr) != CSL_SOK)
{
printf("Error: EDMA clear interrupt bit 1 command is failed\n");
}
/* Close channel */
status = CSL_edma3ChannelClose(hChannel);
if (status != CSL_SOK) {
printf("Edma channel close failed\n");
}
/* Close edma module */
status = CSL_edma3Close(hModule);
if (status != CSL_SOK) {
printf("Edma module close failed\n");
}
/* Test Passed. */
}
void main (void)
{
// Uint8 channelNum1;
// Uint8 channelNum2;
// Int32 regionNum;
Uint8 instNum = 0;
printf ("**************************************************\n");
printf ("******************* EDMA Testing *****************\n");
printf ("**************************************************\n");
int loopIndex;
for (loopIndex = 0; loopIndex < 512; loopIndex++) {
srcBuff1[loopIndex] = loopIndex;
srcBuff2[loopIndex] = loopIndex;
dstBuff1[loopIndex] = 0;
dstBuff2[loopIndex] = 0;
}
edma_chain_xfer_region(instNum, 0,8,5,srcBuff1,dstBuff1,srcBuff2,dstBuff2);
printf("complete.\n");
printf ("**************************************************\n");
printf ("************* EDMA Testing Successful ************\n");
printf ("**************************************************\n");
return;
}
Andy Yin1:
PaRAM set opt 字段的STATIC 字段要配置为0,即这个CSL_EDMA3_STATIC_EN应该修改为为CSL_EDMA3_STATIC_DIS,另外如果要用channel0去chain channel8,则应该将opt的字段TCC填上channel8的value=8.