I'm using PSOC5 and I need to configure an DMA channel to tranfer 16 bit data from a memory table (1024 words) to the compare register in a PWM (16 bit) module. I need to make the transference only once, generate an interruption to advise about the end of the transfer and wait for the next transfer when it is needed.
My problem is that after the transfer the DMA generates the interrupt but doesn't stop and seems to repeat the transfer of the same block for ever
All the examples I've found about the DMA work in a repetitive way, not in one shot as I need. Nevertheless I configured the DMA as follows:
/* DMA Configuration for DMA_PWM */
DMA_PWM_Chan = DMA_PWM_DmaInitialize(DMA_PWM_BYTES_PER_BURST, DMA_PWM_REQUEST_PER_BURST,
DMA_PWM_TD = CyDmaTdAllocate();
CyDmaTdSetConfiguration(DMA_PWM_TD, 2048, DMA_INVALID_TD, DMA_PWM__TD_TERMOUT_EN | TD_INC_SRC_ADR);
CyDmaTdSetAddress(DMA_PWM_TD, LO16((uint32)buffer_pwm), LO16((uint32)PWM_1_COMPARE1_LSB_PTR));
Do you want to transfer all 1024 values in one shot, or each value on request? AFAICS you set the DMA to transfer 2 bytes with each request - how have you wired up the DMA component to generate the burst request? The interrupt should be executed after all 1024 values have been transferred - and the configuration is set to end the DMA then.
I think your code should do what you want - don't know why it doesn't work. One thing you could do is to enable the termination output of the DMA, and use it to stop the timer. That way you don't depend on the exact configuration of the DMA.
I've tryed the value oxFE but I'm getting only one interruption, after that "CyDmaChEnable(DMA_PWM_Chan, 1);" has no effect.
In the mean time I'm using my configuration, then I make "CyDmaChDisable(DMA_PWM_Chan);" in the DMA interruption routine, this stops the DMA. This is nos actually a problem because I have some time between two DMA access, then, when I need again, I call "CyDmaChEnable".