Yahoo Groups archive

Lpc2000

Index last updated: 2026-04-28 23:31 UTC

Thread

FIQ Jitter problem

FIQ Jitter problem

2004-12-16 by itsjustimpossible

Hi
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.

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 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.

I am using the latest Keil beta release of their compiler. The 
device is an LPC2294, cclk=60MHz and pcklk=cclk/2

many thanks
Simon

Re: FIQ Jitter problem

2004-12-16 by lpc2100_fan

Hi Simon,

any particular reason why you don't use the Match Registers or the
PWM? They do it without jitter. 

Is the MAM enabled? MAMTIM?  If the device runs full speed there can
still be jitter but it should be less than 100 ns 

Cheers, Bob

--- In lpc2000@yahoogroups.com, "itsjustimpossible" <simonjh@b...> wrote:
Show quoted textHide quoted text
> 
> Hi
> 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.
> 
> 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 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.
> 
> I am using the latest Keil beta release of their compiler. The 
> device is an LPC2294, cclk=60MHz and pcklk=cclk/2
> 
> many thanks
> Simon

Re: FIQ Jitter problem

2004-12-16 by Karl Olsen

--- 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

Re: [lpc2000] Re: FIQ Jitter problem

2004-12-17 by Robert Adsett

At 11:45 PM 12/16/04 +0000, you wrote:


>--- 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.
> > 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.

I've used this technique for 1-wire support although I wasn't that 
concerned  about that level of jitter.  You can take a look at the code it 
you like (follow the one-wire link from 
http://www.aeolusdevelopment.com/Articles/download.html ).  IT's in the 
adaptation code and is quite short and simple.

Robert

" 'Freedom' has no meaning of itself.  There are always restrictions,
be they legal, genetic, or physical.  If you don't believe me, try to
chew a radio signal. "

                         Kelvin Throop, III

Re: FIQ Jitter problem

2004-12-17 by itsjustimpossible

Firstly, thanks to all those who replied. I had 'in between times' 
switched over to using the PWM to generate the pulses and it works 
fine.

But I still couldn't understand where the jitter was coming from and 
how it was affected by seemingly un-related code changes. I will 
have a read through the document you mentioned but everything you 
say makes sense.
I just wasn't aware that this ammount of jitter could occur.

Thanks again to all.

cheers
Simon

--- In lpc2000@yahoogroups.com, "Karl Olsen" <kro@p...> wrote:
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).

Move to quarantaine

This moves the raw source file on disk only. The archive index is not changed automatically, so you still need to run a manual refresh afterward.