knoxcu / arduino-timerone

Automatically exported from code.google.com/p/arduino-timerone
0 stars 0 forks source link

Incompatible with core Servo and SPI libraries #7

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
The TimerOne library can't be used together with either the Servo or the SPI 
library.
In the case of Servo, TimerOne wins, whereas in the case of SPI, SPI wins and 
TimerOne won't function.
Tested with Arduino 1.0 on an Arduino Pro Micro 328 8MHz.

I suppose this is because Servo and SPI also make use of the Atmel's Timer1? Is 
there some way to workaround this? At least it's interesting that SPI and Servo 
work happily together.

In case it's not solvable, a big warning in the docs would be very useful. :)

Original issue reported on code.google.com by andre.knoerig@gmail.com on 18 Apr 2012 at 4:21

GoogleCodeExporter commented 8 years ago
When you say "The TimerOne library can't be used together with either the Servo 
or the SPI library", do you know if this applies to attachInterrupt as well?

    attachInterrupt(function, period)
    Calls a function at the specified interval in microseconds. 

I just want to use attachInterrupt to trigger SPI to poll for some data ten 
times a second (ie: 10Hz). As there's no PWM involved, is this function safe 
with SPI?

Original comment by lardconc...@gmail.com on 2 Dec 2013 at 9:11

GoogleCodeExporter commented 8 years ago
No idea, sorry. Just give it a try.  :)
Btw, you might find more help in the Arduino Forum for that, as this place is 
just for the Timer One lib.

Original comment by andre.knoerig@gmail.com on 5 Dec 2013 at 8:19

GoogleCodeExporter commented 8 years ago
Hi @andre. I can answer my own question and save anyone else confusion - it 
DOES work.
OK, to clarify, using the attachInterrupt function of this library appears to 
work fine with SPI. Try this code... 
https://gist.github.com/lardconcepts/7836064

BTW, when you say "you might find more help in the Arduino Forum for that, as 
this place is just for the Timer One lib". 

Well, you said "The TimerOne library can't be used together with either the 
Servo or the SPI library". 

I came and questioned this, because I was having trouble (turned out the slave 
select wire to the slave was loose!).

My question was directly related to the TimerOne library, and specific to your 
question, so I thought I'd add it on. Anyway, bottom line is... the answer is 
yes!

Original comment by lardconc...@gmail.com on 7 Dec 2013 at 1:21