TI中文支持网
TI专业的中文技术问题搜集分享网站

TMS320C6748: 关于dma+spi的传输问题

Part Number:TMS320C6748

大家好

 目前代码中先将发送端dma配置好,触发,紧接着将接收端dma配置好,触发,请问这样的方式是否正确?

代码如下:

void DMA_Trans_link(unsigned char *linkbuf, unsigned int linklen, unsigned char *regbuf, unsigned char *rxbuf, unsigned int rxlen)
{
EDMA3CCPaRAMEntry paramSet_Send, paramSet_Recv;//, paramSet_Link;

/*************************************** SEND ***************************************/
memset((unsigned char *)&paramSet_Send, 0, sizeof(paramSet_Send));
// memset((unsigned char *)&paramSet_Link, 0, sizeof(paramSet_Send));
/* Fill the PaRAM Set with transfer specific information. */

/* srcAddr holds address of memory location buffer. */
paramSet_Send.srcAddr = (unsigned int) regbuf;

/* destAddr holds address of SPIDAT1 register. */
paramSet_Send.destAddr = (unsigned int) (SOC_SPI_1_REGS + SPI_SPIDAT1);

/* aCnt holds the number of bytes in an array. */
paramSet_Send.aCnt = (unsigned short) 1;

/* bCnt holds the number of such arrays to be transferred. */
paramSet_Send.bCnt = (unsigned short) 1;//txlen;

/* cCnt holds the number of frames of aCnt*bBcnt bytes to be transferred. */
paramSet_Send.cCnt = (unsigned short) 1;

paramSet_Send.srcBIdx = (short) 1;

/* Linking transfers in EDMA3 are not used. */
paramSet_Send.linkAddr = (unsigned short)(32 * 127);//0xFFFF; 

/* Set TCC field in OPT with the tccNum. */
// paramSet_Send.opt |= ((EDMA3_CHA_SPI1_TX << EDMA3CC_OPT_TCC_SHIFT) & EDMA3CC_OPT_TCC);
//
// /* EDMA3 Interrupt is enabled and Intermediate Interrupt Disabled.*/
// paramSet_Send.opt |= (1 << EDMA3CC_OPT_TCINTEN_SHIFT);

/* Now write the PaRam Set to EDMA3.*/
EDMA3SetPaRAM(SOC_EDMA30CC_0_REGS, EDMA3_CHA_SPI1_TX, &paramSet_Send);

/***************************************/
paramSet_Send.srcAddr = (unsigned int) linkbuf;

/* bCnt holds the number of such arrays to be transferred. */
paramSet_Send.bCnt = (unsigned short) linklen;//txlen;

/* Linking transfers in EDMA3 are not used. */
paramSet_Send.linkAddr = (unsigned short)0xFFFF;

/* Set TCC field in OPT with the tccNum. */
paramSet_Send.opt |= ((EDMA3_CHA_SPI1_TX << EDMA3CC_OPT_TCC_SHIFT) & EDMA3CC_OPT_TCC);

/* EDMA3 Interrupt is enabled and Intermediate Interrupt Disabled.*/
paramSet_Send.opt |= (1 << EDMA3CC_OPT_TCINTEN_SHIFT);

/* Now write the PaRam Set to EDMA3.*/
EDMA3SetPaRAM(SOC_EDMA30CC_0_REGS, 127, &paramSet_Send);//

/* EDMA3 Transfer is Enabled. */
EDMA3EnableTransfer(SOC_EDMA30CC_0_REGS, EDMA3_CHA_SPI1_TX, EDMA3_TRIG_MODE_EVENT);
/************************************************************************************/

/*************************************** RECV ***************************************/
memset((unsigned char *)&paramSet_Recv, 0, sizeof(paramSet_Recv));
/* Fill the PaRAM Set with transfer specific information. */

/* srcAddr holds address of memory location buffer. */
paramSet_Recv.srcAddr = (unsigned int) (SOC_SPI_1_REGS + SPI_SPIBUF);

/* destAddr holds address of SPIDAT1 register. */
paramSet_Recv.destAddr = (unsigned int) rxbuf;

/* aCnt holds the number of bytes in an array. */
paramSet_Recv.aCnt = (unsigned short) 1;

/* bCnt holds the number of such arrays to be transferred. */
paramSet_Recv.bCnt = (unsigned short) rxlen;

/* cCnt holds the number of frames of aCnt*bBcnt bytes to be transferred. */
paramSet_Recv.cCnt = (unsigned short) 1;

paramSet_Recv.destBIdx = (short) 1;

/* Linking transfers in EDMA3 are not used. */
paramSet_Recv.linkAddr = (unsigned short) 0xFFFF;

/* Set TCC field in OPT with the tccNum. */
paramSet_Recv.opt |= ((EDMA3_CHA_SPI1_RX << EDMA3CC_OPT_TCC_SHIFT) & EDMA3CC_OPT_TCC);

/* EDMA3 Interrupt is enabled and Intermediate Interrupt Disabled.*/
paramSet_Recv.opt |= (1 << EDMA3CC_OPT_TCINTEN_SHIFT);

/* Now write the PaRam Set to EDMA3.*/
EDMA3SetPaRAM(SOC_EDMA30CC_0_REGS, EDMA3_CHA_SPI1_RX, &paramSet_Recv);

/* EDMA3 Transfer is Enabled. */
// EDMA3EnableTransfer(SOC_EDMA30CC_0_REGS, EDMA3_CHA_SPI1_TX, EDMA3_TRIG_MODE_EVENT);
EDMA3EnableTransfer(SOC_EDMA30CC_0_REGS, EDMA3_CHA_SPI1_RX, EDMA3_TRIG_MODE_EVENT);
/************************************************************************************/

SPIIntEnable(SOC_SPI_1_REGS, SPI_DMA_REQUEST_ENA_INT);
}

我采用这样 的方式    目前的问题是当走过这个函数后,会进入SYS_INT_EDMA3_0_CC0_ERRINT中断,查看手册进入这个中断说明第一次中断处理过程中,第二次中断进入(个人理解,可能是错误的,还望指正),那是否说明我上面的这段代码是有问题的?

请TI的工程师能给与解答

谢谢

Shine:

可以参考starterware里的C:\ti\C6748_StarterWare_1_20_04_01\examples\lcdkC6748\spi_edma例程。http://software-dl.ti.com/dsps/dsps_public_sw/c6000/starterware/01_20_04_01/index_FDS.html

赞(0)
未经允许不得转载:TI中文支持网 » TMS320C6748: 关于dma+spi的传输问题
分享到: 更多 (0)