Apparent buffer overflow when using DMA with HS ADC

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Apparent buffer overflow when using DMA with HS ADC

723 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by hairy.lee on Wed Jun 08 07:34:30 MST 2016
Hi,

I'm running the HS ADC at 12MHz and, using the LabTool code as a basis for capturing a block of samples, sampling a 10kHz Sine Wave. I'm not interested in trigger levels.

Using a waveform generator attached to the EXP_ADC0_DAC input of my LPC Link 2 board I can capture 8192 packed samples to SRAM (0x2000 0000 -> 0x2000 4000). However, when I dump them out and plot them (see 12kHz Sine image) I observe what appears to be either missed samples or a wrap around, I suspect the later. If anyone can identify the glaring mistake I'm making it would be appreciated as I clearly cant; Am I not terminating the process correctly in the ISR or is it a configuration issue?

Thanks in advance.

HL

Original Attachment has been moved to: HSADC.c.zip

Labels (1)
0 Kudos
3 Replies

548 Views
lpcware
NXP Employee
NXP Employee
bump
0 Kudos

548 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by hairy.lee on Thu Jun 09 02:05:51 MST 2016
Hey,


Quote:
I may be wrong



Nope, that was the glaringly obvious omission I hoped someone would notice and point out. Very much appreciated, thanks!

HL
0 Kudos

548 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by heffalump on Wed Jun 08 17:39:23 MST 2016
Hi there,

I had a quick look at your code, it appears you are relying on your interrupt handler dmaIrqCallback(void) to halt the transfer? In my experience interrupts have significant latency, particularly if they are running from FLASH. By the time the interrupt has halted the transfer, the circular buffer created by the LLI has looped around.

If you want a single trace of 8192 samples with no circular buffering, you can set DMA to halt after the LLI element is complete using

 DMA_Stuff[DMA_NUM_LLI_TO_USE - 1].ctrl |= (0x1UL << 31); // Terminal count interrupt enabled

DMA_Stuff[DMA_NUM_LLI_TO_USE - 1 ].lli = 0;  //Stop Transfer 


I may be wrong, but I hope this helps!

Good luck!
0 Kudos