AnsweredAssumed Answered

DMA with SPI on KL25z with mlx camera

Question asked by mahieu lucas on Nov 13, 2016
Latest reply on Dec 2, 2016 by Kerry Zhou

Hey, 

I try to make a communication between the spi of kl25z and  mlx camera.

I have to get the data thanks to DMA.

 

With oscilloscope I succeed to see that I send the right command byte to the mlx.

 

I receive some data from the mlx, but I don't succeed to get it. 

 

Can you look at my dam_init, because the software is blocking on the "enable_irq(INT_DMA0 - 16);" fonction call.

 

void dma_init(void){

new_dma_data=0;
// Enable clocks
SIM_SCGC6 |= SIM_SCGC6_DMAMUX_MASK;
SIM_SCGC7 |= SIM_SCGC7_DMA_MASK;

 

// Config DMA Mux for ADC operation
// Disable DMA Mux channel first
DMAMUX0_CHCFG0 = 0x00;

 

// Configure DMA
DMA_SAR0 = (uint32_t) &SPI0_D;
DMA_DAR0 = (uint32_t) spi_rdata;
DMA_DSR_BCR0 = DMA_DSR_BCR_BCR(3); // transfert de 3 octets via le DMA

 

DMA_DCR0 |= (DMA_DCR_EINT_MASK| // Enable interrupt
DMA_DCR_ERQ_MASK | // Enable peripheral request
DMA_DCR_SSIZE(1) | // Set source size to 8 bits
DMA_DCR_DINC_MASK| // Set increments to destination address
DMA_DCR_DSIZE(1)); // Set destination size of 8 bits 

 


// Enable DMA channel and source
DMAMUX0_CHCFG0 |= DMAMUX_CHCFG_ENBL_MASK | DMAMUX_CHCFG_SOURCE(16); // Enable DMA channel and set SPI0 receive as source cf doc KL25P80M48SF0RM.pdf p64-65

 


// Enable interrupt
enable_irq(INT_DMA0 - 16);
}

 

thanks in advance 

 

lucas

Outcomes