Wait implementation

03 Jun 2010

I was pleased to see the new documentation on the implementation of wait(), but it didn't really add much. I assume you are not simply adding NOPs (as suggested) as this would change if I changed the core frequency, so how is it done?

Use of wait is a short term thing, I will replace it with a timer interrupt, but currently I'm sitting in a loop using wait() to time some SPI writes. When I look at the output on a scope I see that the timing of the wait appears to vary by a discrete interval of about 1us on some loops. So if I'm expecting 24us I sometimes get 25us, but nothing in between.

If it is not wait(), then is it possible that a synchronisation issue causes SPI writes to sometimes take longer to get started?

03 Jun 2010

Hi Mark,

Wait is based on a 1us free running timer, as used also by Timer, Ticker, Timeout, so that'll be what you are seeing. Nothing to do with the SPI device.

Thanks!

Simon