SPI with DMA enabled

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

SPI with DMA enabled

1,428 Views
leepenn
Contributor III

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 */
}

0 Kudos
Reply
3 Replies

675 Views
marek_neuzil
NXP Employee
NXP Employee

Hello,

I have tried to reproduce the problem but the simple application with SynchroMaster component work properly with the Output DMA support enabled in the SynchroMaster component. I have used CW MCU 10.6 and 56F8400 tower board with MC56F84789 derivative (the MC56F84763 is a phantom). I used the default settings of SynchroMaster, set the timing (Shift clock rate = 10,24us clock, Wait Deleay 1us), enabled Output DMA support and I used a simple loop to send data (I have tested SendBlock() and SendChar() methods), see below:

SynchroMaster with DMA on MCF56F847xx.png

Application code of the main module:


void main(void)

{

  /* Write your local variable definition here */

  SM2_TComData test_data[10] = "123456789";

  word size_to_send, send_count;

  volatile byte err;

  /*** Processor Expert internal initialization. DON'T REMOVE THIS CODE!!! ***/

PE_low_level_init();

  /*** End of Processor Expert internal initialization.                    ***/

  /* Write your code here */

size_to_send = 9;

  for(;;) {

    /* SendBlock method test code */

        //err = SM2_SendBlock(test_data, size_to_send, &send_count);

   /* SendChar method test code */

    err = SM2_SendChar(test_data[0]);

  }

   for(;;) {}

}

I have encountered a problem with debugging only. When I debugged the application the QSPI (with DMA) does not send data. But when the application was run the data were properly sent (I have checked output signals from QSPI).

Please note that the Destination address of the DMA is set in the initialization code of the QSPI and DMA. It is a constant because the QSPI Data Trasnmit register is used (the word address of the QSPI0_SPDTR register is 0xE0B3 and byte address 0x1C166; see the MC56F847xx reference manua), see the DMA properties below:

DMA of QSPI on MC56F847xx.png

I think that your issue can be caused by many reason. Do you use the DMA by any other device (component) in your project? What is your setting of the CPU? If you want to help to resolve the issue post your application to this discussion thread for analysis please.


Best Regards,

Marek Neuzil

675 Views
leepenn
Contributor III

Marek,

I am using DMA for ADC and would also like to try and use it for RS232 and SPI. My SPI settings with my dma on looks very similar? Did just running with Debuger unplugged allow your spi dma to work or did you have to change settings? I have attached a view of my DMA setup, and the pef for my whole project.

DMA.png

0 Kudos
Reply

675 Views
marek_neuzil
NXP Employee
NXP Employee

Hello,

I have checked the settings of your application and it seems that there is missing settings of External DMA request in the DMA:Init_DMA component.If you are using ADC12_RSTL0 register and you want to copy results of ADC12 (Cyclic) to your ADC_Array you must select the right trigger signal that start the DMA request. In you case it should be ADCA_ES signal (ADCA (Cyclic) End of Scan). See screenshot below.

Note: You need also enable teh DMA request of the ADC12 device. It seems correctly configured in the settings of the ADC_MEASUE:Init_ADC component in your project.

Init_DMA ADC settings on MC56F84763.png

ADCA_ES settings MC56F847xxRM.png

Best Regards,

Marek Neuzil


0 Kudos
Reply