wait_us() jitter..

30 Jul 2010

Hi,

Has anyone noticed that wait_us() has about 500ns of jitter. It's not much, but at short wait times it could cause some problems. I took some waveform traces. The wait time shown below is either 3.5us or 4us. I can understand why the pulse is not exactly 3us wide, but what gets me is that it changes between two values.. Also, for wait_us(2), the pulse is very stable. And at one point during testing, the pulse was stable for only even numbers of wait..

I thought it was a problem with the DigitalIO implementation, but when I use a simple NOP loop delay, it can produce a (very) stable pulse down to 150ns, shown below. The issue is not much of a problem beyond 10us, so I don't think its much of a bother to most people, I was just curious..

The figure below is from the following code snippet:

 

DigitalOut out(p14);
...
while (1){
out=1;
wait_us(3);
out=0;
wait_us(1000);
}

31 Jul 2010

Hi Igor,

This is a great analysis! Yes, the jitter you are seeing is due to the fact all the mbed time functions work from a running 1us ticker, hence you will get only as acurate as within 1us of the requested time.

Simon

16 Oct 2013

Hi Simon,

we have a project with serious timing issues and I do not agree, why a 1µs ticker should cause a 500ns jitter. Igor's scope looks like we see anything between 3.5 and 4 µs - although I'm not able to see the probability distribution. If any (software) timer runs on 1µs cycle, I would expect a statistical maximum at 3 µs and another at 4 µs, but not all in between. Also, we still see here a delay of 500µs: the pulse is never shorter then 3.5 µs.

Matthias

You need to log in to post a reply