This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

DMA triggered by EPWMSOC

Hello,

The DMA has several options on which peripheral interrupt triggers a transfer. I'm looking to sample 4 different input channels and have them all trigger a DMA transfer independently after each conversion is completed. Unfortunately, there are only 2 ADCINTs able to be selected for a DMA channel (page 825 Technical Reference Manual).

There are also EPWMSOCA and B for EPWM2 through 7. I could potentially use these to trigger the DMA channels, but I'm concerned that this will trigger the DMA at the start of conversion, before a new sample has actually been placed in the ADC result register. Then, instead of transferring new data at each SOC, I would just be transferring the data that was leftover in the register. Can anybody explain the timing here? If DMA takes enough time to get started, such that by the time it performs the transfer, the new result is in the ADC result register, than this will work perfectly. 

Or is there a better way to do this that I am missing entirely?

Thanks,

Matthew

  • Hi Matthew,

    Maybe you can do this.

    Configure SOC0 to convert your first ADC channel, SOC1 for second ADC channel, SOC2 for 3rd channel and SOC3 for the last channel. 

    The same EPWM trigger can be set to trigger conversions on all channels. Because all the channels will be triggered at the same time, the ADC will convert them in round robin fashion. Then ADCINT1 can be configured for EOC of the last channel converted. (in your case it would be EOC3). Finally you can have ADCINT1 trigger DMA transfers. This will ensure that DMA always transfers the latest results.

    Thanks,

    Vivek

  • Thanks Vivek. This should be great for when I sample 4 separate channels, because then I can do a simple "duration of sampling" subtraction to calculate the specific times at which I am sampling.

    However, I also need to sample one signal at 4X the rate (so all SOCs sample the same channel). The system has two different sections-- one with a reference collection, where I collect a very high frequency signal on one channel, the second section collects new data that is experimental, where I collect 4 different channels, then correlate these values to the very high frequency reference. I was hoping to be able to use very similar code for both sections so that I could cut down on the amount of initialization code. 

    For the reference signal, the time between each sample needs to be the same, which I don't think is achievable with the method you propose (unless ADCINT is set back to trigger SOC0-3? This would make it run continuously, presumably making this seamless. What do you think?). Although you are right, it is an ideal option for the experimental section. 

    Also, I guess I could use two different methods, but that means I'm going to need to add more "initialization code". 

    The method I was thinking about using was 4 different PWMs that were all synced together, and they all trigger their own respective SOC (I could do this with 2 PWMs if I used SOCA and SOCB). This SOC could trigger both the ADC to start a sampling process AND the DMA. This would allow me to have maximum control over the frequencies I'm using and the timing, but I just don't know if the DMA would take the results before or after the conversion. Any ideas on how I can find out? 

  • Hi Matthew,

    My point is why would you want to trigger DMAs from PWM if you are unsure of the instant at which the DMA collects the result. Your best bet is to have ADCINTs trigger the DMAs right?

    (I might be wrong though. It might be some kind of DMA implementation issue. Haven't used DMA in my projects. Haven't had the need to actually)

    Vivek