howto DSPI EDMA Slave MK64

cancel
Showing results for 
Search instead for 
Did you mean: 

howto DSPI EDMA Slave MK64

511 Views
ulrichriedel
Contributor I

Hello

I tried slave SPI with DMA on MK64  FRDM K64E with the example from 9.4 DSPI Slave Driver

Kinetis SDK v.1.1 API Reference Manual

No data is transfered...

What is wrong?

Thank you

short g_dma_read[128];

short g_dma_write[128];

    edma_state_t       edmaState;

    edma_user_config_t edmaUserConfig;

    dspi_edma_slave_state_t       dspiEdmaSlaveState;

    dspi_edma_slave_user_config_t slaveEdmaUserConfig;

    dspi_status_t result;

    PORT_HAL_SetMuxMode(PORTD_BASE, 0, kPortMuxAlt2); // PTD0 SPI0_PCS0  CS slave, 1 CLK high 19 CLK low

    PORT_HAL_SetMuxMode(PORTD_BASE, 1, kPortMuxAlt2); // PTD1 SPI0_SCK   CLK slave with continious 15 MHz clock

    PORT_HAL_SetMuxMode(PORTD_BASE, 2, kPortMuxAlt2); // PTD2 SPI0_SOUT

    PORT_HAL_SetMuxMode(PORTD_BASE, 3, kPortMuxAlt2); // PTD3 SPI0_SIN

    memset(&edmaUserConfig, 0, sizeof(edmaUserConfig));

    edmaUserConfig.chnArbitration = kEDMAChnArbitrationRoundrobin;

    EDMA_DRV_Init(&edmaState, &edmaUserConfig);

    memset(&dspiEdmaSlaveState, 0, sizeof(dspiEdmaSlaveState));

    memset(&slaveEdmaUserConfig, 0, sizeof(slaveEdmaUserConfig));

    slaveEdmaUserConfig.dataConfig.clkPhase    = kDspiClockPhase_FirstEdge;

    slaveEdmaUserConfig.dataConfig.clkPolarity = kDspiClockPolarity_ActiveHigh;

    slaveEdmaUserConfig.dataConfig.bitsPerFrame = 19;

    slaveEdmaUserConfig.dummyPattern = 0;

    DSPI_DRV_EdmaSlaveInit(0, &dspiEdmaSlaveState, &slaveEdmaUserConfig);  // DSPI0

  // g_dma_write, g_dma_read is previously filled with testpattern, to make sure to debug

    // make SPI transfer

    result = DSPI_DRV_EdmaSlaveTransfer(0, // SPI0

                                        (const uint8_t *) g_dma_write,

                                        (uint8_t *)       g_dma_read,

                                        100);

    while(kStatus_DSPI_Success != DSPI_DRV_EdmaSlaveGetTransferStatus(0, NULL)) {

      __asm(" NOP");

    }

Tags (4)
0 Kudos
1 Reply

174 Views
Alice_Yang
NXP TechSupport
NXP TechSupport

Hi Ulrich,

There are several reasons for  no data transfer , firstly , be sure the correct link spi ,

and I suggest only use SPI without DMA test , check whether it can transfer data.

If it can transfer data well, then  check the spi-dma project .

Hope it helps

Alice

0 Kudos