AnsweredAssumed Answered

SPI with DMA enabled

Question asked by Lee Penn on Nov 28, 2014
Latest reply on Feb 16, 2015 by Marek Neuzil

Hi,

 

I am using PE with CW 10.6 for creating code for use with a MC56F84763 to send data across the SPI0 using DMA. When I do not enable Output DMA Support on Transmit for SPI0 I can see the data being transmitted on a scope. When I do enable it I do not see anything. I had noticed that the generated code does not create a SetDestinationAddress call, so I added it manually and still no output from SPI. Below are the three iterations of the functions I tried and was wondering if anyone sees anything I am missing.

 

Thanks,

 

Lee

 

Works without DMA

byte Samples_SPI_SendChar(Samples_SPI_TComData Chr)
{
  if (SerFlag & FULL_TX) {             /* Is any char in the TX buffer? */
    return ERR_TXFULL;                 /* If yes then error */
  }
  EnterCritical();                     /* Disable global interrupts */
  SerFlag |= FULL_TX;                  /* Set the flag "full TX buffer" */
  setReg(QSPI0_SPDTR,Chr);             /* Store char to transmitter register */
  setRegBit(QSPI0_SPSCR,SPTIE);        /* Enable transmit interrupt */
  ExitCritical();                      /* Enable global interrupts */
  return ERR_OK;                       /* OK */
}

 

DMA enabled Missing Inhr1_SetDestinationAddress no output

byte Samples_SPI_SendChar(Samples_SPI_TComData Chr)
{
  if (Inhr1_GetStatus() == DMA_ENABLED) { /* Is the DMA channel enabled? */
    return ERR_TXFULL;                 /* If yes then error */
  }
  BufferWrite = Chr;                   /* Copy character to the temporary buffer */
  EnterCritical();                     /* Disable global interrupts */
  Inhr1_SetSourceAddress(&BufferWrite); /* Set the source address for DMA transfer */
  Inhr1_SetDataSize(1U);               /* Set requested DMA data size */
  Inhr1_Start();                       /* Start TX DMA transfer */
  ExitCritical();                      /* Enable global interrupts */
  return ERR_OK;                       /* OK */
}

 

DMA enabled added Inhr1_SetDestinationAddress manually still no output

byte Samples_SPI_SendChar(Samples_SPI_TComData Chr)
{
  if (Inhr1_GetStatus() == DMA_ENABLED) { /* Is the DMA channel enabled? */
    return ERR_TXFULL;                 /* If yes then error */
  }
  BufferWrite = Chr;                   /* Copy character to the temporary buffer */
  EnterCritical();                     /* Disable global interrupts */
  Inhr1_SetSourceAddress(&BufferWrite); /* Set the source address for DMA transfer */
  Inhr1_SetDestinationAddress(QSPI0_SPDTR); /* Added this for destination of DMA Transfer */
  Inhr1_SetDataSize(1U);               /* Set requested DMA data size */
  Inhr1_Start();                       /* Start TX DMA transfer */
  ExitCritical();                      /* Enable global interrupts */
  return ERR_OK;                       /* OK */
}

Outcomes