I am working on a project which supposed to sample an external ADC at regular intervals (at 16kHz).
The ADC conversion is triggered by Timer. This timer also generates an event to trigger a DMA based SPI transmission (two bytes each time).
An interrupt is triggered after several triggers to process the gathered data.
The processor goes into the standby mode between processing received data, and only SPI and the DMA is working at this time.
To save as much energy as possible, I decided to throttle the MCLK (which is also used to drive the DMA) during the sleep mode.
The problem is, that throttling the DMA clock is also altering DMA's response time. This is most visible during the clock speed change event.
It causes the SPI packets not being sent in phase with the ADC trigger signal (acting also as the CS) during the clock speed change, and some of the SPI packets are lost.
Attached is a screenshot with signals:
- D0-D2 SPI
- D3 Trigger (from Timer), used also as a SPI CS signal
- D4 Indicates When MCU is awake in with fast CLK.
Is there any way to force or tweak the DMA to let's say delay its response to an event in certain circumstances (i.e. switching it's CLK to a different frequency) ?