switching between 2 DMA channels

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
Anonymous
Not applicable

Hi ,

   

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) );
TD_rx_1= CyDmaTdAllocate();
CyDmaTdSetAddress(TD_rx_1, LO16(((uint32)SPIS_RXDATA_PTR)), LO16(((uint32)slaveRxDataBuffer_1));
CyDmaTdSetConfiguration(TD_rx_1,MAX_BUFFER_SIZE, 0xFF,TD_INC_DST_ADR);
CyDmaChSetInitialTd(channel_rx_1, TD_rx_1);
CyDmaChEnable(channel_rx_1, 0)

   

stopping (when packet is over) using :

   

CyDmaTdGetConfiguration(TD_rx_1,&dma_location,0,0); //get size of packet
CyDmaChDisable(channel_rx_1);
CyDmaChFree(channel_rx_1);
CyDmaTdFree(TD_rx_1);

   

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 ?  

0 Likes
1 Reply
AnkitaS_51
Employee
Employee
100 likes received 50 likes received 25 likes received

Please post your project

0 Likes