Hi there!
I am trying to sample an analog signal using the EK-TM4C123GXL evaluation board. I would like to control the sampling frequency of a single ADC up to the maximum declared speed of 1Msps. From my understanding the ADC would take 16 cycles @ 16Mhz from trigger to making the data available in the FIFO.
I would use the following setup:
- Use a General Purpose Time to trigger the ADC at the right speed (I guess that for a single sample the timer should count 80 clock cycles - if the CPU is running @80Mhz in order to trigger the ADC @1Msps)
- Use uDMA to transfer 1024 samples to a buffer in memory
- In the last uDMA interrupt stop the timer to end the AD conversion
While this is the general outline I came with a couple of questions I could not answer:
1. One idea was to setup the ADC SS0 to sample 8 measurements and trigger a ping-pong transfer on the uDMA side.
- In this case each sample would be triggered independently by the timer or the whole train of 8 samples would be ran one after the other @16Mhz? In other words, am I able to control the speed at which the 8 measurements are sampled?
- I was thinking to trigger the uDMA every 4 samples. In this case the arbitration size would need to be 4. However, which should be the transfer size for the DMA buffers? Should it be 4 updated at every transfer, the total number of samples (1024) or each buffer would have to be setup with half of that?
2. Another approach could be to trigger via the timer a single measurement and transfer it to the buffer via DMA. Would this be feasible at 1Msps?
3. From what I understand the DMA would mask the ADC interrupts and emit only one completion interrupt at the end of the conversion or in case of ping-pong transfer mode after each transfer. Is this understanding correct?
4. Is there a simple way (using debugger, saving data into a variable, ...) to measure the real sampling frequency, meaning clock cycles from trigger to completion and make sure that the FIFO buffer is never overflown, considering that the interrupt from ADC would be masked by the DMA?
I am sorry if some of these questions are elementary/naïve. I am still learning microcontroller programming, so if you have any previous post, some code example or section of the datasheet I should read in more depth, please let me know!
Thank you for your support