I am using PSOC5LP. cy_dma IP, latest revision (1.7). PSOC Creator 4.1.
I repeatedly configure the same DMA chain to run a single pass collecting of a Delta-Sigma ADC data. The DMA is triggered by ADC's EOC, and ADC's SOC is triggered by PWM. The code to configure the DMA is pasted below. I ensure that PWM is stopped before that code is executed and that PWM output and DS EOC output are low and not pulsing. I enable the PWM after the configuration is complete.
The problem is that for every run after the initial one, right after CyDmaChanEnable() is called, the DMA appears to go active (state returned by last call to CyDmaChStatus
has bit 1 set and I see that the very first word in the DMA buffer changes. Nothing else happens until I enable the PWM - at that point, data starts filling in starting from the second word in the buffer.
Now, if I call the below sequence twice before enabling the PWM, then the second invocation of it results in DMA remaining idle after CyDmaChanEnable() and DMA sequence properly starting to feel at the first buffer location. I.e., I have a workaround. But the behavior does not make sense. I tried various things (see commented liens - CyDmaChDisable, CyDmaClearPendingDrq) - all to no avail. I even tried releasing and reinitializing the DMA channel itself - also without luck.
Help would be much appreciated.
int dma_config(uint16 len)
uint8 td, state;
// check the current state - if not idle, send a termination request and spin on completion