Problems with SPI over DMA

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

Problems with SPI over DMA

Jump to solution
735 Views
adithyakirank
Contributor I


Hi,


I am using a Kinetis KM34Z128AXXX5 to write SPI data over DMA. The SPI and DMA have been setup correctly as far as my understanding goes, but there is no data on the SPI lines when I check with an oscilloscope. The SPI and DMA code is as below:

 

 

SE_INT08U data[4] = { 0xAA,0xAA,0xAA,0xAA };

 

#define SPI_MODULE_CUSTOM_CONFIG                                               \

(tSPI){                                                                        \

/* C1   */ CLR(SPI_C1_SPIE_MASK)|SET(SPI_C1_SPE_MASK)|CLR(SPI_C1_SPTIE_MASK)|  \

/* ..   */ SET(SPI_C1_MSTR_MASK)|CLR(SPI_C1_CPOL_MASK)|CLR(SPI_C1_CPHA_MASK)|  \

/* ..   */ CLR(SPI_C1_SSOE_MASK)|CLR(SPI_C1_LSBFE_MASK),                       \

/* C2   */ CLR(SPI_C2_SPMIE_MASK)|CLR(SPI_C2_SPIMODE_MASK)|                    \

/* ..   */ SET(SPI_C2_TXDMAE_MASK)|CLR(SPI_C2_MODFEN_MASK)|                    \

/* ..   */ CLR(SPI_C2_RXDMAE_MASK)|CLR(SPI_C2_SPISWAI_MASK)|                   \

/* ..   */ CLR(SPI_C2_SPC0_MASK),                                              \

/* C3   */ 0,   /* C3 is not used for SPI0 module due to no FIFO support */    \

/* BR   */ SET(SPI_BR_SPPR(0))|SET(SPI_BR_SPR(2)),                             \

/* ML   */ 0,                                                                  \

/* MH   */ 0,                                                                  \

}

 

SPI0_Init( SPI_MODULE_CUSTOM_CONFIG, NULL, 0, NULL);

 

DMA_InstallCallbackDMA0( PRI_LVL3, &dma_cb );

 

DMA0_Init(DMA_CH_SWTRG_M2P_CN_CONFIG(data,DMA_SIZE8BIT,0x40075006,4)); 

 

while(DMA_IsDone(DMA0));

 

 

// Callback for DMA

void dma_cb(DMA_CH_CALLBACK_TYPE type)

{

    if( type == DONE_CALLBACK )

    {

     

    }

}

Labels (1)
1 Solution
456 Views
MarMi
NXP Employee
NXP Employee

Hi Kiran,

I think the issue is in using "continuous" DMA transfer instead of a "cycle steal" one. The DMA configuration structure that should be used is DMA_CH_HWTRG_M2P_CS_CONFIG(..). The cycle steal transfer performs just one transfer for every DMA request.

The SP1 TX operation over DMA is shown in the attached example - SPI1 was selected because of PTF6/SPI1_MOSI is easily accessible for monitoring on TWR-KM34Z50M.

Kind regards,

Martin M.

View solution in original post

2 Replies
456 Views
adithyakirank
Contributor I

Thanks Martin! That did it for me. I had tried the DMA_CH_HWTRG_M2P_CS_CONFIG configuration earlier but I guess my overall setup was wrong somewhere ( I suspect the SPI TXDMAE bit ). 

0 Kudos
457 Views
MarMi
NXP Employee
NXP Employee

Hi Kiran,

I think the issue is in using "continuous" DMA transfer instead of a "cycle steal" one. The DMA configuration structure that should be used is DMA_CH_HWTRG_M2P_CS_CONFIG(..). The cycle steal transfer performs just one transfer for every DMA request.

The SP1 TX operation over DMA is shown in the attached example - SPI1 was selected because of PTF6/SPI1_MOSI is easily accessible for monitoring on TWR-KM34Z50M.

Kind regards,

Martin M.