Good morning everyone,
for several weeks I have been trying to implement ADC data acquisition through DMA on a circular buffer on micro iMXRT1020, I ask you for help.
DESIRED OPERATION
The board provides 8 analog inputs that go to an external MUX whose single output enters into iMX on an analog input. The application must sample this input, transfer the data via DMA and move the GPIOs to drive the external MUX on the next channel. The process must work in a continuous loop so I have implemented a circular buffer on which to store the data.
What I have done, following SDK examples and material online is:
- Enable a PIT timer at the desired sample rate
- Configure XBARA with PIT input and ADC_ETC output
- Enable ADC on channel 1
- Configure ADC_ETC with CHAIN_LENGTH = 1
- Configure two EDMA channels like this:
TCD [1]
- source = ADC
- destination = circular buffer
- source data size = 2 (12bit)
- target data size = 2
- byte each minor loop = 2
- total number of bytes = 2
- Minor link connected to itself
- Major link connected to channel 0
Enabling the 32byte destination module
TCD [0]
- source = constant buffer containing mux configuration
- destination = GPIO-> DR
- source data size = 4 (size of a given source)
- target data size = 4 (GPIO log size)
- byte each minor loop = 4
- total number of bytes = 4
- Memory -> peripheral
- Minor link connected to itself
Enable the 32byte source module
In this way, the circular loop works: at each tick of the PIT I have an acquisition of the ADC channel, a data transfer in the DMA buffer [1] and an increase of the MUX DMA channel [0].
PROBLEM 1:
To do this, however, I had to enable the interrupt of the ADC and inside I must necessarily call
EDMA_EnableChannelRequest (DMA0, CH1);
otherwise the dma transfers only the first data and then it is as if it were no longer re-armed.
This is not good for me, it loses the sense of use of the dma.
between the different tests, I tried to modify the number of transfers (n) but in doing so I obtain that at the trigger of the PIT, the ADC converts and the DMA transfers the same data n times (which will have the same value).
PROBLEM 2:
on other platforms I'm used to using circular buffers like this: at each conversion ADC triggers the DMA which transfers the data. The dma is configured to circularly transfer N data and provides a half-transfer interrupt and a complete-transfer interrupt that the application uses to determine what the pointer to valid data is.
The system implemented in this way, however, does not allow me this system as the dma provides an interrupt every transfer and not every half or whole buffer.
Anyone have any suggestions? I have practically reached the evaluation time limit of this hardware that is blocking the project and the probable alternative is to change component.
thank you