AnsweredAssumed Answered

MCP5566: Adapting DMA example for the UART

Question asked by Zachary Wilcox on May 13, 2019
Latest reply on May 14, 2019 by Zachary Wilcox

I'm adapting the DMA BlockMove example to use the ESCIA A to transmit data.

I can transmit over the ESCIA with out DMA.  However, nothing is transmitted when attempting to use the DMA engine

 

I'm sure it's something minor.  Any idea why DMA isn't sending data to the ESCIA for transmit?

The inner for loop completes but not the outer while loop

 

#include "MPC5566.h"
#include "esci.h"

const  uint8_t  SourceData[] = {"Hello WorldDMA\r\n"};     /* Source data string */
uint8_t  Destination = 0;
void initTCD18(void) {

  EDMA.TCD[18].SADDR = (vuint32_t) &SourceData;  /* Load address of source data */
  EDMA.TCD[18].SSIZE = 0;                        /* Read 2**0 = 1 byte per transfer */
  EDMA.TCD[18].SOFF = 1;                         /* After transfer, add 1 to src addr*/
  EDMA.TCD[18].SLAST = -12;                      /* After major loop, reset src addr*/
  EDMA.TCD[18].SMOD = 0;                         /* Source modulo feature not used */

  EDMA.TCD[18].DADDR = (vuint32_t) &Destination; /* Load address of destination */
  EDMA.TCD[18].DSIZE = 0;                        /* Write 2**0 = 1 byte per transfer */
  EDMA.TCD[18].DOFF = 0;                         /* Do not increment destination addr */
  EDMA.TCD[18].DLAST_SGA = 0;                    /* After major loop, no dest addr change*/
  EDMA.TCD[18].DMOD = 0;                         /* Destination modulo feature not used */
 
  EDMA.TCD[18].NBYTES = 1;                       /* Transfer 1 byte per minor loop */
  EDMA.TCD[18].BITER = 12;                       /* 12 minor loop iterations */
  EDMA.TCD[18].CITER = 12;                       /* Initialize current iteraction count */
  EDMA.TCD[18].D_REQ = 1;                        /* Disable channel when major loop is done*/
  EDMA.TCD[18].INT_HALF = 0;                     /* Interrupts are not used */
  EDMA.TCD[18].INT_MAJ = 0;
  EDMA.TCD[18].CITERE_LINK = 0;                  /* Linking is not used */                                              
  EDMA.TCD[18].BITERE_LINK = 0;
  EDMA.TCD[18].MAJORE_LINK = 0;                  /* Dynamic program is not used */
  EDMA.TCD[18].E_SG = 0;
  EDMA.TCD[18].BWC = 0;                          /* Default bandwidth control- no stalls */
  EDMA.TCD[18].START = 0;                        /* Initialize status flags */
  EDMA.TCD[18].DONE = 0;
  EDMA.TCD[18].ACTIVE = 0;
}

int main(void) {
  volatile int i = 0;

  esci_init_default(ESCI_A_ID);
  esci_setBaudRate(ESCI_A_ID, 9600);

  //This transmit works!
  WriteUARTN("hello world2\r\n", 13);

  initTCD0();
  EDMA.CR.R = 0x0000E400; /* Use fixed priority arbitration for DMA groups and channels */
  EDMA.CPR[18].R = 0x0;  /* Channel 18 priorites: group priority = 0, channel priority = 0 */
 
  EDMA.SERQR.R = 18;      /* Enable EDMA channel 18 */
  EDMA.SSBR.R = 18;


  //This doens't work :(
  while (EDMA.TCD[18].CITER != 1)
  { /* while not on last minor loop */
                                    /* wait for START=0 and ACTIVE=0 */
    while ((EDMA.TCD[18].START == 1) | (EDMA.TCD[18].ACTIVE == 1)) {}
    EDMA.SSBR.R = 18;     /* Set channel 18 START bit again for next minor loop transfer */ 
  }

  /* Loop forever */
  for (;;)
  {
   
    i++;
  }
}



Outcomes