--- In lpc2000@yahoogroups.com, "itsjustimpossible" <simonjh@b...>
wrote:
>
> I don't know if anyone else has seen this but its driving me nuts.
> I have timer1 on a 40uS interval triggering an FIQ. (All the FIQ
> does is toggle an IO pin and exit.) No other interrupts are active.
>
> In practice the leading edge of the pulse produced on the IO pin
> jitters by around 230nS to 280nS around the 40uS interval.
Chapter 2.9 in the ARM7TDMI TRM:
http://www.arm.com/pdfs/DDI0029G_7TDMI_R3_trm.pdf
says that the FIQ latency is between 5 and 29 clocks. The long
latencies only happen if you have slow instructions like LDM R0,[R0-
R15] in the main program. Loads and stores to the Philips
peripherals are also relatively slow. But still if you only have
NOPs and a loop branch in the main program, you must expect a jitter
of several clocks (nop = 1 clock, branch = 5 clocks if you use MAM
and MAMTIM=3).
> The really wierd thing is if I change the main code routine, ie add
> lines or comment things out, the extent of the jitter changes. In
> fact if I pad my code out with some 'asm{nop;}' by trial and error
I
> can get rid of the jitter completely.
>
> Whilst the FIQ is active the rest of the code is in a loop. At
> present, just checking for a flag to change state.
I would expect the maximum jitter to be the difference between the
fastest and the slowest instruction in the main program. And you may
be lucky that the FIQ "always" happens during a fast instruction.
> I need this pulse to be as accurate as possible, a few nS jitter at
> most. If anyone can shed some light on this I would be very
grateful.
You can't achieve such low jitter using FIQ (unless your main program
consists entirely of 1-clock instructions). One clock is 16.6 ns.
As another poster suggested, you can use the PWM or match outputs to
get a jitter of 0 clocks. Using a match output is probably the
easiest - if you want to use the PWM, be sure to read all the fine
print about when new MRx values take effect.
For timer 0 or 1, you can set a match register to the time when you
want a MATx.x pin to toggle, and configure T0EMR/T1EMR to toggle it.
You can also set "interrupt on match" so you get an interrupt in
which you can reprogram the next match time or EMR mode.
> I am using the latest Keil beta release of their compiler. The
> device is an LPC2294, cclk=60MHz and pcklk=cclk/2