AnsweredAssumed Answered

FTM Input capture working, but DMAMUX, eDMA is not

Question asked by Brian Willoughby on Aug 11, 2015
Latest reply on Aug 12, 2015 by Earl Orlando Ramirez Sanchez

I'm trying to measure the period of an external signal using the FTM Input capture mode and DMA.

 

Using Processor Expert, I added Init_FTM and successfully have FTM0 working from the Fixed Frequency Timer and using Input capture mode to see the count on each rising edge of my measured signal. If I poll the FTM registers quickly enough (the input signal is only 5 Hz to 100 Hz max), I can see that the difference between each captured count is exactly as expected when compared to an oscilloscope probing the input pin.

 

I'm using Channel 1 of FTM0, not Channel 0, because the FTM0_CH1 pin was available on my board. I have Channel interrupt disabled, but DMA request enabled, assuming that this is necessary to trigger the eDMA.

 

For some reason, the DMA is not functioning. I have an instance of the ftm_edma component in PE, with a single configuration. Auto initialization is checked, and Init configuration 0 has FTM0_Channel1_Signal selected as the Request. Channel is Fixed, and is set to DMA_Channel4 (it seems prudent to leave channels 0 through 3 because they have additional capabilities). I assume that the latter two settings (Request & Channel) are all that is needed to configure the DMAMUX properly. I've checked Callback and have a function named dma_Controller1_Callback4. On the Interrupts page, I have all DMA channel interrupts disabled except for INT_DMA4. DMA channel interrupt priority is enabled and set to minimal priority. Install interrupt is enabled, and the ISR name is dmaController1_Chn4IRQHandler.

 

When running, breakpoints show that the DMA interrupt is not called. Examining memory, it seems that the DMA never writes any value.

 

In my code, I call EDMA_DRV_PrepareDescriptor(), EDMA_DRV_PushDescriptorToReg(), and EDMA_DRV_StartChannel()

 

Is there anything more I need to do to ensure that the DMAMUX and eDMA peripherals are properly configured and enabled? I've looked at the Processor Expert Generated Code, and it seems that everything there is correct. I'm just not sure whether anything is missing. Is there a DMAMUX component needed? Do the eDMA settings take care of the DMAMUX initialization? Where are the #define values for the K64F that list the options available on my chip?

 

It would be nice to get DMA working, because my polled method cannot always be called frequently enough to catch every period of the signal.

 

p.s. My initial assumption about Input capture mode was that it would reset the timer counter after each copy of the count value to the FTM0_C1V register. If that worked as I expected, each captured value would represent the length of the period in timer ticks. However, I learned from running the code so far that the timer counter is not reset with each capture, so I have to catch two sequential capture values and calculate the difference to know the period. This means I cannot miss a capture without the difference doubling or more. Therefore, if there happens to be a setting for the FTM that will reset the timer counter after the Input capture feature has copied the count to the value register, then my code would be simplified and probably more robust. Any hints here would be appreciated as well.

Outcomes