I am attempting to collect data coming into a SPI port and transfer it from the SPI port using the DMA. Initially, I was using Channel 0 of the DMA and it worked, but when testing for a long period of time, the DMA stopped transferring sporadically. I am now at a point where the DMA won't transfer anymore. Even cycling power to the board does not help.
I found DMA errata 9: https://www.ti.com/lit/er/slaz574v/slaz574v.pdf?ts=1636610126959 and attempted the second work-around, by adding Channel 2 as well. Once again, there was no transfer occurring.
In the routine where the DMA is enabled, I check if the flag has been triggered for either channel, which would cause the program to leave the loop. I know I can leave the loop, using an interrupt when the user selects to stop collecting data, which causes the flag to be set and thus the program leaves the data acquisition mode. The condition in question is:
while (((DMA0CTL & DMAIFG) == 0) && ((DMA2CTL & DMAIFG) == 0));
I set the DMAEN bit prior to collecting data and disable it after the loop condition, which continually cycles through set and reset until the user is finished.
The rest of my DMA setup is as follows:
// DMA setup for ADC
DMA0CTL &= ~DMAEN; // disable DMA
DMA0SA = (WORD) &ASPI_RXBUF; // source address is the RX buffer from the ADC
DMA0DA = (WORD) &ADCOUT[0]; // destination address is a byte array that will store 6 bytes (L0, L1, L2, L3, R0, R1)
DMACTL0 |= DMA0TSEL_16; // Initiate DMA transfer on USCIB1RX this mean the transfer will occur when a byte is received into the USCI B1 RX buffer
DMACTL4 |= DMARMWDIS; // DMA transfers disabled during read-modify-write cycle of the CPU
DMA0CTL &= ~DMAIFG; // clear any potential pending interrupts
DMA0CTL |= DMADT_0 + DMADSTINCR_3 + DMASBDB; // Repeated single transfer mode, inc destination address, source is a byte, dest is a byte, edge sensitive trigger
DMA0SZ = 0x06; // transfer size is 6 bytes (L0, L1, L2, L3, R0, R1)
// to fix errata DMA9: https://www.ti.com/lit/er/slaz574v/slaz574v.pdf?ts=1636610126959
DMA2CTL &= ~DMAEN;
DMA2SA = (WORD) &ASPI_RXBUF;
DMA2DA = (WORD) &ADCOUT[0];
DMACTL1 |= DMA2TSEL_16;
DMA2CTL &= ~DMAIFG;
DMA2CTL |= DMADT_0 + DMADSTINCR_3 + DMASBDB;
DMA2SZ = 0x06;