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);
}

Replies

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

Please log in to post a reply.