AnsweredAssumed Answered

MPC5744P SPI Cannot Respond to DMA Requests When Using DMA Transfers

Question asked by zhou wei on May 24, 2018

Dear members
I hope that when the SPI slave function automatically stores data in the specified array every time data comes in, instead of receiving each interrupt, the DMA does not work as expected after configuration. My configuration code is as follows:
void init_dma_mux_CH16()
{
DMAMUX_1.CHCFG[16].R = 0x00;///关闭通道16
DMAMUX_1.CHCFG[16].B.ENBL =1;
DMAMUX_1.CHCFG[16].B.SOURCE =4;//通道16的源为4(for SPI1 RX)
DMAMUX_1.CHCFG[16].B.TRIG=0;///不采用定时触发模式
}
///////////////////////
void initTCDs_CH16(void)
{
DMA_0.TCD[16].SADDR.R = ((unsigned int)&SPI_1.POPR.R) + 3; /* Load source address*/
////////地址为SPI1 RX数据寄存器
DMA_0.TCD[16].ATTR.B.SSIZE = 0; /* Read 2**0 = 1 byte per transfer */
DMA_0.TCD[16].ATTR.B.SMOD = 0; /* Source modulo feature not used */
DMA_0.TCD[16].SOFF.R = 0; /* After transfer add 0 to src addr*/
DMA_0.TCD[16].SLAST.R =0; /* After major loop, reset src addr*/

DMA_0.TCD[16].DADDR.R = (unsigned int) Re_Buffer_CH16; /* Load dest. address*/
DMA_0.TCD[16].ATTR.B.DSIZE =0; /* Write 2**0 = 1 byte per transfer*/
DMA_0.TCD[16].ATTR.B.DMOD = 0; /* Dest. modulo feature not used */
DMA_0.TCD[16].DOFF.R = 1; /* After transfer add 1 to dst addr*/
DMA_0.TCD[16].DLASTSGA.R = -10; /* After major loop no dest addr change*/

DMA_0.TCD[16].NBYTES.MLNO.R = 1; /* Transfer 1 byte per minor loop */
DMA_0.TCD[16].BITER.ELINKNO.B.ELINK = 0; /* No Enabling channel LINKing */
DMA_0.TCD[16].BITER.ELINKNO.B.BITER = 10; /* 12 minor loop iterations */
DMA_0.TCD[16].CITER.ELINKNO.B.ELINK = 0; /* No Enabling channel LINKing */
DMA_0.TCD[16].CITER.ELINKNO.B.CITER = 10; /* Init. current iteraction count */

DMA_0.TCD[16].CSR.B.DREQ = 0; /*Enable channel when major loop is done*/
DMA_0.TCD[16].CSR.B.INTHALF = 0; /* No interrupt when major count half complete */
DMA_0.TCD[16].CSR.B.INTMAJOR = 0; /* No interrupt when major count completes */
DMA_0.TCD[16].CSR.B.MAJORELINK = 0; /* Dynamic program is not used */
DMA_0.TCD[16].CSR.B.MAJORLINKCH = 0; /* No link channel # used */
DMA_0.TCD[16].CSR.B.ESG = 0; /* Scatter Gather not Enabled */
DMA_0.TCD[16].CSR.B.BWC = 0; /* Default bandwidth control- no stalls */
DMA_0.TCD[16].CSR.B.START = 0; /* Initialize status flags START, DONE, ACTIVE */
DMA_0.TCD[16].CSR.B.DONE = 0;
DMA_0.TCD[16].CSR.B.ACTIVE = 0;

DMA_0.SERQ.B.SERQ = 16; ///设置16通道DMA请求
DMA_0.ERQ.B.ERQ16 = 1; ///使能通道16请求

}
//////////////////////////////////////////////////
void init_edma_channel_arbitration (void) { /* Use default fixed arbitration */

DMA_0.CR.R = 0x0000E400; /* Fixed priority arbitration for groups, channels */

DMA_0.DCHPRI[0].R = 0x00; /* Grp 0 chan 00, no suspension, no premption */
DMA_0.DCHPRI[1].R = 0x01; /* Grp 0 chan 01, no suspension, no premption */
DMA_0.DCHPRI[2].R = 0x02; /* Grp 0 chan 02, no suspension, no premption */
DMA_0.DCHPRI[3].R = 0x03; /* Grp 0 chan 03, no suspension, no premption */
DMA_0.DCHPRI[4].R = 0x04; /* Grp 0 chan 04, no suspension, no premption */
DMA_0.DCHPRI[5].R = 0x05; /* Grp 0 chan 05, no suspension, no premption */
DMA_0.DCHPRI[6].R = 0x06; /* Grp 0 chan 06, no suspension, no premption */
DMA_0.DCHPRI[7].R = 0x07; /* Grp 0 chan 07, no suspension, no premption */
DMA_0.DCHPRI[8].R = 0x08; /* Grp 0 chan 08, no suspension, no premption */
DMA_0.DCHPRI[9].R = 0x09; /* Grp 0 chan 09, no suspension, no premption */
DMA_0.DCHPRI[10].R = 0x0A; /* Grp 0 chan 10, no suspension, no premption */
DMA_0.DCHPRI[11].R = 0x0B; /* Grp 0 chan 11, no suspension, no premption */
DMA_0.DCHPRI[12].R = 0x0C; /* Grp 0 chan 12, no suspension, no premption */
DMA_0.DCHPRI[13].R = 0x0D; /* Grp 0 chan 13, no suspension, no premption */
DMA_0.DCHPRI[14].R = 0x0E; /* Grp 0 chan 14, no suspension, no premption */
DMA_0.DCHPRI[15].R = 0x0F; /* Grp 0 chan 15, no suspension, no premption */

DMA_0.DCHPRI[16].R = 0x10; /* Grp 1 chan 00, no suspension, no premption */
DMA_0.DCHPRI[17].R = 0x11; /* Grp 1 chan 01, no suspension, no premption */
DMA_0.DCHPRI[18].R = 0x12; /* Grp 1 chan 02, no suspension, no premption */
DMA_0.DCHPRI[19].R = 0x13; /* Grp 1 chan 03, no suspension, no premption */
DMA_0.DCHPRI[20].R = 0x14; /* Grp 1 chan 04, no suspension, no premption */
DMA_0.DCHPRI[21].R = 0x15; /* Grp 1 chan 05, no suspension, no premption */
DMA_0.DCHPRI[22].R = 0x16; /* Grp 1 chan 06, no suspension, no premption */
DMA_0.DCHPRI[23].R = 0x17; /* Grp 1 chan 07, no suspension, no premption */
DMA_0.DCHPRI[24].R = 0x18; /* Grp 1 chan 08, no suspension, no premption */
DMA_0.DCHPRI[25].R = 0x19; /* Grp 1 chan 09, no suspension, no premption */
DMA_0.DCHPRI[26].R = 0x1A; /* Grp 1 chan 10, no suspension, no premption */
DMA_0.DCHPRI[27].R = 0x1B; /* Grp 1 chan 11, no suspension, no premption */
DMA_0.DCHPRI[28].R = 0x1C; /* Grp 1 chan 12, no suspension, no premption */
DMA_0.DCHPRI[29].R = 0x1D; /* Grp 1 chan 13, no suspension, no premption */
DMA_0.DCHPRI[30].R = 0x1E; /* Grp 1 chan 14, no suspension, no premption */
DMA_0.DCHPRI[31].R = 0x1F; /* Grp 1 chan 15, no suspension, no premption */
}
///////////////////////////////////////
void init_dspi_1(void)
{
SPI_2.MCR.R = 0x00010001; /* Configure DSPI_2 as slave */
SPI_2.MODE.CTAR[0].R = 0x38000000; /* Configure CTAR0 : 8 Bit */
SPI_2.RSER.R = 0x00030000; /* Enable DMA for RX */

SPI_2.MCR.B.HALT = 0x0; /* Exit HALT mode: go from STOPPED to RUNNING state*/
SPI_2.SR.R = 0xFCFE0000; /* Clear ALL status flags by writing 1 */
}
The other SPI configuration is normal (using interrupts to receive data normally); when the host sends data, the slave using this code cannot update Re_Buffer_CH16 (uint8_t array), please guide the question where?
thank you very much

Outcomes