Hello,
I'm working on a maple_mini with libmaple 0.12.
I'm using DMA to feed a SPI double DAC (mcp4822)...
I'm trying to send both channel (left right) in one DMA request of 4 bytes. I need an interupt after 2 bytes to do some GPIO modification to validate the first channel.
First question : during the DMA half transmission IRQ, do the DMA transfer stop ?
Can i assume during the interupt that only 2 bytes have been sent and that it will continue only when the IRQ function exits ?
My main problem is that the DMA_HALF_TRNS is never called... DMA_TRNS_CMPLT works.
The consequences is that with the following i only have one of the stero channel working.
Here's the init :
spi.begin(SPI_18MHZ, MSBFIRST, 0); dma_init(DMA1); spi_tx_dma_enable(SPI1); dma_setup_transfer(DMA1, DMA_CH3, &SPI1->regs->DR, DMA_SIZE_8BITS, &samples, DMA_SIZE_8BITS, (DMA_MINC_MODE | DMA_TRNS_CMPLT | DMA_HALF_TRNS | DMA_FROM_MEM)); dma_attach_interrupt(DMA1, DMA_CH3, DMAEvent); dma_set_priority(DMA1, DMA_CH3, DMA_PRIORITY_VERY_HIGH);
Then in an IRQ called every 1/32768 sec (sampling frequency = 32768Khz):
dma_set_num_transfers(DMA1, DMA_CH3, 4); dma_enable(DMA1, DMA_CH3);
And the DMAEvent function :
void DMAEvent() { //we get the DMA event dma_irq_cause event = dma_get_irq_cause(DMA1, DMA_CH3); if (event == DMA_TRANSFER_COMPLETE) { csHigh(); dma_disable(DMA1, DMA_CH3); synth.incReadCursor(); } else { csHigh(); delay(100); // Tells me it never calls else it should not work with such a delay!! csLow(); } }
Is there any minimal number of bytes in the DMA transmition to be called in the middle ?
Thanks a lot for any help,
Xavier