Part Number: DK-TM4C129X
I'm working on a timing critical ADC unloading process which I have working, but with downstream processing taking about 50% longer than I want. The ADC is an 8 channel 18 bit SAR that I'm unloading in about 4.8 us using 20 MHz SPI (QSSI) and uDMA. That gets me a 9 x 16bit block with the 8 x 18bit samples "barber polled" through it. At present I'm using a uDMA memory scatter gather transfer to unpack the 18bit samples into 32bit words. I then left shift the 32bit words to get the data correctly aligned and copy the result to an output queue. The align and copy process takes about 1.5 us with locally optimized code.
However the scatter gather uDMA process seems to take almost 6 us using processor memory with the processor running at 60 MHz. The process makes 8 transfers of 3 bytes each. There is no other DMA processing contending for the bus. Ideally I'd like to the unpack processing under 3 us which lets me run the ADC at 100 kHz.
Does 6 us sound about right for 8 x 3 byte uDMA scatter gather transactions?
What may influence the total transaction time?
My setup code is:
// Set up scatter gather processing to unpack 18 bit samples from DMA // buffer into 32 bit sample block uint8_t *byteSource = reinterpret_cast<uint8_t *>(sDMARxBuffer); size_t taskIdx = 0; while (*inputNums && taskIdx < 8) { size_t srcByteOffset = (*inputNums - 1) * 18 / 8; ++inputNums; sSampleXferTable[taskIdx] = uDMATaskStructEntry( 3, UDMA_SIZE_8, UDMA_SRC_INC_8, byteSource + srcByteOffset, UDMA_DST_INC_8, sSamplesUnpackBuffer + taskIdx, UDMA_ARB_2, !*inputNums ? UDMA_MODE_AUTO : UDMA_MODE_MEM_SCATTER_GATHER ); ++taskIdx; } IntRegister(UDMA_INT_SW, CommitSamples); IntEnable(UDMA_INT_SW); uDMAChannelAttributeEnable(UDMA_CHANNEL_SW, 0); // Give scatter gather DMA processing high priority UDMA_PRIOSET_R = 1 << UDMA_CHANNEL_SW; // Set up unpack pointers uDMAChannelScatterGatherSet(UDMA_CHANNEL_SW, 8, sSampleXferTable, 0);
Is there another way I could solve this problem? One possibility is overlapping the ADC unloading and sample unpacking uDMA processes, but I haven't had much success in making that work.