AnsweredAssumed Answered

SPC5606B DSPI EDMA problem

Question asked by shu lizhong on Mar 19, 2018

I use spc5606b test DSPI send and receive data via EDMA, every time send data size is difference(1-44byte), TCD Complete Interrupt is enable, but the EDMA can't triggered sometimes, when  sent complete. When I use oscilloscope see the wave, find every LOSE trigger, then the send count is 1BYTE. The MCU's configuration show follow.

 


static const unsigned short TX_EDMA_CH[DSPI_QTY]={0,2,4,6};
static const unsigned short RX_EDMA_CH[DSPI_QTY]={1,3,5,7};
BOOL DSPI_TransmitString(unsigned int index, unsigned short *p, unsigned int len)
{
 unsigned int i;
 
 if(index >= DSPI_QTY)
 {
  return FALSE;
 }
 
 if(len > DSPI_TrnsRcvData[index].Size)
 {
  return FALSE;
 }
 
 if( (DSPI_TrnsRcvData[index].State == DS_BUSYING)  ||
  (DSPI_TrnsRcvData[index].State == DS_TRANSFER))
 {
  return FALSE;
 }
 
 
 EDMA.TCD[TX_EDMA_CH[index]].INT_MAJ = 0;
 EDMA.TCD[RX_EDMA_CH[index]].INT_MAJ = 0;
 EDMA.ERQRL.R &= ~((1 << TX_EDMA_CH[index]) | (1 << RX_EDMA_CH[index]));
 EDMA.TCD[TX_EDMA_CH[index]].SLAST = (vint32_t) (0-len*EDMA.TCD[TX_EDMA_CH[index]].NBYTESu.R);/* Last signed Source Address Adjust */
 EDMA.TCD[TX_EDMA_CH[index]].BITER  = len;/* Current Major Iteration Count or Link Channel Number  */
 EDMA.TCD[TX_EDMA_CH[index]].CITER  = len;/* Current Major Iteration Count or Link Channel Number  */
 
 EDMA.TCD[RX_EDMA_CH[index]].DLAST_SGA = (vint32_t) (0-len*EDMA.TCD[RX_EDMA_CH[index]].NBYTESu.R);/* Signed Destination Address Offset   */
 EDMA.TCD[RX_EDMA_CH[index]].BITER  = len;/* Current Major Iteration Count or Link Channel Number  */
 EDMA.TCD[RX_EDMA_CH[index]].CITER  = len;/* Current Major Iteration Count or Link Channel Number  */
 
 DSPI[index]->RSER.B.EOQFRE = 0;
 DSPI[index]->SR.B.EOQF = 1;
 DSPI[index]->MCR.B.CLR_TXF = 1; 
 DSPI[index]->MCR.B.CLR_RXF = 1;
 
 DSPI_TrnsRcvData[index].Length = len;
 DSPI_TrnsRcvData[index].State = DS_BUSYING;
 
 if(len < 2)
 {
  DSPI_TrnsRcvData[index].TxData[0] = ONEBYTE_SIGN | (unsigned int)p[0];
 }
 else
 {
  DSPI_TrnsRcvData[index].TxData[0] = START_SIGN | (unsigned int)p[0];
  
  for(i=1;i<len - 1;i++) 
  {
   DSPI_TrnsRcvData[index].TxData[i] = MIDDLE_SIGN | p[i];
  }
  
  DSPI_TrnsRcvData[index].TxData[i] = END_SIGN | p[i];
 }
 
 DSPI_TrnsRcvData[index].State = DS_TRANSFER;
 EDMA.ERQRL.R |= ((1 << TX_EDMA_CH[index]) | (1 << RX_EDMA_CH[index]));
 EDMA.TCD[TX_EDMA_CH[index]].INT_MAJ = 1;
 EDMA.TCD[RX_EDMA_CH[index]].INT_MAJ = 1;
 
 return TRUE;
}

BOOL DSPI_DisableInterrupt(unsigned int index)
{
 if(index >= DSPI_QTY)
 {
  return FALSE;
 } 
 
 EDMA.TCD[TX_EDMA_CH[index]].INT_MAJ = 0;
 EDMA.TCD[RX_EDMA_CH[index]].INT_MAJ = 0;
 
 return TRUE;
}
BOOL DSPI_EnableInterrupt(unsigned int index)
{
 if(index >= DSPI_QTY)
 {
  return FALSE;
 } 
 
 EDMA.TCD[TX_EDMA_CH[index]].INT_MAJ = 1;
 EDMA.TCD[RX_EDMA_CH[index]].INT_MAJ = 1;
 
 return TRUE;
}

 

Outcomes