I am having problems with unpredictable DMA transfers. sometimes everything works, sometimes it seems that the DMA is either not working at all or running over data structures in memory.
I have a SPI-Slave connected to 2 different DMA components. each responsible for copying data from the SPIS to a different buffer.
the idea is to switch the active DMA between the two allowing time to handle the data in the other buffer without losing data. since the packet size is dynamic, a mechanism is in place to get the position of the DMA destination address so a packet size could be calculated.
setting the DMA is using (example for one of the channels):
channel_rx_1 = DMA_Rx_1_DmaInitialize(1,1, HI16((uint32)SPIS_RXDATA_PTR), HI16((uint32)(slaveRxDataBuffer_1) );
CyDmaTdSetAddress(TD_rx_1, LO16(((uint32)SPIS_RXDATA_PTR)), LO16(((uint32)slaveRxDataBuffer_1));
stopping (when packet is over) using :
CyDmaTdGetConfiguration(TD_rx_1,&dma_location,0,0); //get size of packet
this repeats (enabling and disabling) every time a packet is received. jumping from DMA A to DMA B as the active one.
only the drq on the active one will be triggered.
is this the best way to jump between 2 DMA channels ? is there something wrong with the setup/stopping of the DMA ?
Please post your project