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.

HW timer problem in capture mode

Hi,

I have tested the HW timer in free mode and compare mode (with direct access to the registers in both cases) and all was fine (counter was ok and interrupt was generated in compare mode).

However, I have been trying to make the HW Timer to work in capture mode and I did not succeed at all. I am using AM3559 micro.

The dedicated input trigger seems not to work (no interrupt is raised, and no values are loaded into the TCAR registers). I have used TIMER4 input (I tried with TIMER7 later as well).

What I need is saving the current timer value into the TCAR registers when a change/pulse in the timer dedicated input is detected.

This is my configuration:

Multiplex:
Configure dedicated pin as TIMER4 peripheral.

Interrupts: (I suppose this should be fine, as interrupt triggers in compare mode)
Set register INTC_ILR92 to 0 (max priority)
Set bit 92%32 on INTC_MIR3 to 1 to enable interrupt

DMTimer module:
Disable timer: set TCLR to 0
Re-load 0 in overflow: set TLDR to 0
Clear initial count: set TCRR to 0
Enable interrupt: set TIMER_IRQ_CAPTURE to IRQENABLE_SET --> value = (1<<2)
Enable timer: set TIMER_START | TIMER_AUTORELOAD | TIMER_CAPTURE_RISING to TCLR --> value = 1 | (1<<1) | (1<<8)
Clear any pending associated interrupt.

(As a fallback solution I am now reading the free running timer value from a GPIO interrupt handler that detects the change; however I would need the most accurate timer value possible).

Thanks in advance.

  • I have run up against this same problem myself and have been unable to find a solution.  I noticed that there have been no replies to your post, but have you been able to resolve this problem?

  • Hi Jeff,

    unfortunatelly, after performing a lot of tests I was not able to find a solution, so I finally gave up trying to find the problem and used the typical GPIO interupt workaround.

    BR,

    David

  • David:

    Not sure if this is a possible solution for you, but I was able to get the same functionality by using the pwm ecap interface.  This is actually a better solution for my application because the pwm clock runs at 100MHz (versus 24 MHz on the timer), giving me much better precision.  Let me know if you would like further details on how I set this up.

  • Jeff,

    yes, I am still interested in this issue. It would be great if you could post more details about the solution you found.

    Thanks in advance,

    David

  • I am sampling a 48khz clock which I have connected to the ECAP0_IN_PWM0_OUT signal and have done the appropriate pinmux configuration.  I set ECCTL1 to 0x0100 to enable capturing of the rising edge event on my 48khz clock for each of the 4 capture events.  ECCTL2 is set to 0x0016 to allow the timestamp counter to be free-running in continuous mode and to capture in to each of the four capture registers (in a ring buffer fashion).  For my particular application, I only want to get an interrupt on every fourth clock, so I set ECEINT to 0x0002 so that an interrupt is only generated when when the Capture Event 1 is triggered.  Lastly, I just set up an interrupt handler and let it go.  Hope this helps.  Let me know if you have any further questions.

  • Jeff,

    In the meanwhile, I decided to play a bit more with the timer peripheral and managed to make TIMER4 work in capture mode.

    I am using BeagleBone board for performing the tests, and TIMER 4 input seems to be damaged on the unit I usually work with. I tried other BeagleBone unit and it works fine, but only if I force the multiplex configuration (I was not doing it before). Actually, I was not setting any multiplex configuration at all in the TIMER 4 dedicated pin, as on BeagleBone, this pin was supposed to work as TIMER4 peripheral by default (and input/ouput configuration done by means of timer registers). I just configured TIMER4 pin multiplex with (IEN | MODE2) and it worked!

    However, thank you very much for your information. I will try your indications as your method provides a higher accuracy.

  • Hi Jeff,

    when you say appropriate pinmux configuration, did you use the device tree?

    I am trying to do exactly what you are describing here. I can see the counter running but strobing the port does not trigger an event.

    Jacques