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.

Trigger EDMA every 1-N External Clocks

I’m able to user Timer 4 to trigger EDMA using the technique described in http://e2e.ti.com/support/arm/sitara_arm/f/791/t/359154. My application uses Timer 4 to count external pulses (TCLKIN) then triggers EDMA using the compare (TMAR) register. One of the DMA chains updates Timer 4 TCRR to set the number of input pulses to count until the next match.  It appears there’s a 2 clock pipeline delay between when the compare occurs until the new TCRR value written by the EDMA takes effect.

The following sequence describes what’s happening. The external Timer 4 clock input is 20Khz (slow). Each step below represents a new clock input transition. Initial conditions for this example are TMAR = 20 and TCRR = 19. This should generate a match (and EDMA) every 2 clock pulses but it actually takes 4.

  1. TCRR increments to 20. Internally, Timer 4 does not detect the match until the next clock.

  2. TCRR increments to 21. Timer 4 detects prior TCRR matches TMAR. Timer 4 sets trigger output pulse high and EDMA is triggered which writes 19 to TCRR. EDMA finished before next clock.

  3. TCRR advances to 22. Timer 4 sets trigger output pulse low.

  4. TCRR is finally loaded with 19 set by EDMA in step 2. On next clock, repeat starting at step 1.

So how am I able to tell TCRR runs past 20? I have a tight code loop that continuously reads TCRR and sets 3 GPIO signals indicating the value (20, 21, 22).

So getting back to my goal, how can I initiate EDMA every 1-N input pulses? Right now I can only do 3-N pulses. I need the DMA to change the number of pulses the timer counts until the next EDMA, without a padding of 2 clocks like it does now.

I tried updating TMAR instead of TCRR or using Timer 4 overflow but I still can’t get below 3 input clock transitions between EDMAs. There appears to be pipeline delays in the timer. I’m presently using POSTED mode (bit set in TSICR). My understanding is POSTED READ/WRITE is related to the internal OCP clock, not external clock.

  • Hi,

    Check sections 20.1.3.10 and 20.1.3.11 in the AM335X TRM Rev. M. These discuss posted v. non-posted access.
  • Clearing POSTED didn’t help. That relates to the OCP clock, not TCLKIN. I think the problem is TCRR load and TMAR match require 2 additional TCLKIN edges. What’s needed is to async load TCRR and compare it to TMAR on the next TCLKIN transition, and generate the interrupt. This would allow an interrupt to occur from 1-N TCLKIN transitions. My tests indicate Timer 4 requires a minimum of 3 TCLKIN transitions to generate an interrupt after updating TCRR. There may be another way to achieve this with Timer 4 or some other peripheral. Any ideas would be greatly appreciated.

  • I got this to work with eQEP. The position counter has async behavior. For my application, when QPOSCNT underflows, an interrupt/event is generated initiating an EDMA update of QPOSCNT, which immediately loads without waiting for the next QCLK (derived from EQEPxA input ). That same EDMA chain also sets the PCU and INT flags in QCLR to clear the interrupt. This allows another underflow interrupt/event as soon as the next QCLK. EDMA transfers can now occur every 1-N QCLKs based on the value EDMA writes into QPOSCNT. My initial tests verify proper operation with a 1 KHz to 1 MHz external clock into EQEPxA.