Putting data from an ADC interrupt into DMA memory location

Thanks to anyone that reads and can help with this.

I am using an Arduino MKR 1310 board and attempting to do everything on this board which includes continuous fast ADC sampling at 500,000 sps (2 usec/sample) and then processing the data to search for a pulse height and outputting the number of pulses every 250 msec.

I have tried 2 different methods using information online, but each has different issues, so I would like to combine them if possible - hence the subject line of the post.

In essence, I am trying to use a dual buffer system where I can collect data to one buffer and process the other at the same time as data is being collected. Processing must be faster than data collection for this reason.

If I use an ADC interrupt and place the data into an array, it appears I run out of processing resources and the time to process is longer than data acquisition. The ADC works OK, sampling at whatever rate I want, but as I increase the speed of the clock using a Phase locked loop (PLL), the processing time for the array actually increases. I suspect the processor time is all being taken up by the interrupt and the processing is using what remains.

In my other sketch, I am putting the ADC read data into DMA memory. The issue with the way I have found this method is that it is performed consecutively with the processing. Acquire, process, acquire, process…I have even tried to make a dual channel DMA access which still appeared to work but not sure if it was really different memory allocations. In this program I can see that processing takes 40% of the time to acquire data.

What I would like to try now, is to use the interrupt request program, but instead of putting the data into an array, have it put into a DMA buffer. I thought it would be a straightforward swap for the array, but I think I am having issues with interrupts or something - it locks up the board and becomes unrecognizable to the USB.

Has anyone done something similar to this and have any code to share? I understand the ADC fairly well at this point but DMA is still mass confusion about how to structure it, what code I need and implementing it.

Cheers - Don