Strictly necessary cookies are on by default and cannot be turned off. Functional, Performance and Tracking/targeting/sharing cookies can be turned on below based on your preferences (this banner will remain available for you to accept cookies). You may change your cookie settings by deleting cookies from your browser. Then this banner will appear again. You can learn more details about cookies HERE.
Strictly necessary (always on)
Functional, Performance and Tracking/targeting/sharing (default off)
I am working on this project where I have 7 multiplexed channels going to a SAR ADC. The output of the ADC is going to a DMA channel and it stores the 7 conversions in RAM.
I'm having an issue where the measurement location has an offset and I'd like to reset the DMA pointer every time I service the interrupt to make sure I don't have swapped channels. Is there a way to reset the DMA pointer?
You can terminate a TD. Also if you Enable the DMA with preserveTds = 1.
Here's an excerpt from the DMA datasheet:
cystatus CyDmaChEnable(uint8 chHandle, uint8 preserveTds) Description: Enables the DMA channel. A software or hardware request still must happen before the channel is executed. Note While the channel is enabled and is currently being serviced by the DMA controller, any other configuration information for the channel should NOT be altered to ensure graceful operation. Parameters: uint8 chHandle: A handle previously returned by CyDmaChAlloc() or DMA_DmaInitalize(). uint8 preserveTds: Preserves the original TD state when the TD has completed. This parameter applies to all TDs in the channel.
When a TD is completed, the DMAC leaves the TD configuration values in their current state, and does not restore them to their original state.
When a TD is completed, the DMAC restores the original configuration values of the TD.
Is this the answer you were looking for?
Len "Engineering is an Art. The Art of Compromise."
I've tried your suggestion and I still can't get it to work reliably. Here is a little more detail on how I have it designed.
I have a clock that toggles a 3 bit counter using the rising edge. This counter sets the address to a an analog mux. The falling edge of this clock starts the ADC conversion.
I also have a compare block that looks for the counter equals to 7. If so, that will trigger an interrupt.
In this interrupt, I am reading all 7 readings. The issue is that the DMA is sometimes out of sync with the clock. That's why I want to re-start the DMAs at every interrupt event. Here is a snippet of my code.
//Restart DMA channels so ADC channels are aligned
When running this, the DMA complete signals get completely confused. Are there any suggestions on what I'm doing wrong?
DMA is intended for automatic (unattended) operation. If you intend resetting DMA on each interrupt, it may be easier just not to use DMA at all, performing all operation by processor itself. It may be, actually, faster.