SPI interferes with ticker

20 Oct 2010

I have published a small program:

ticker_test5

That demonstrates a problem I'm having with a program that uses two Tickers and an SPI.

One ticker goes every 200uS, the other every 10,000uS.

In the fast ticker I toggle LED4, and have a wait_us(2) call.  If I probe LED4 I expect to see a 2uS pulse every 200uS on the scope.  I see them, but I also see other pulses randomly interspersed between them.  Like my ISR is being called by something else, or like the Ticker is being short circuited and calling the ISR early sometimes.

The SPI connection?  In main.cpp the slow ticker calls spi.write().  If those three calls are commented out then the ISR calls look fine, a 2uS pulse every 200uS.

So, to see the bug:

compile ticker_test5

run it

probe LED4 with a scope, and observe the extra random pulses.

To get rid of the bug:

comment out the three spi.write() calls in main.cpp

run it

probe LED4 with a scope and observe the clean pulses.

looking forward to hearing what causes this...

--steve