I've been reading https://learn.adafruit.com/ir-sensor where it says that a digitalWrite "takes about 3 microseconds to happen" (they use an Arduino board, but don't specify what model). It's a timing critical part where interrupts are briefly disabled, so I want to adjust for my Teensy 3.2's higher speed. Would it be a simple proportion like Arduino MHz / Teensy MHz which I would use to scale down the 3 microseconds? I get (16/96) * 3 = 0.5 microseconds. I'm not too confident with this assumption.
Before posting, I searched here using "digital write time" and looked over the 163 post results. I did find out about digitalWriteFast, do I understand correctly that this only takes one clock cycle?! So at 96MHz it would only be about 10 NANOseconds?! If so, that would simplify things greatly since I would just ignore that time altogether
Just in case you want to see the code from the tutorial that I'm pondering:
I know there are Libraries for IR, but I've never used a library before (although I'm working towards using them). I like this tutorial because iit's real down'n'diirty so I can really cut my teeth on what is actually going on. Libraries are great for a good end result, but I need to learn the hard way for experience.
Thanks for your time.
Before posting, I searched here using "digital write time" and looked over the 163 post results. I did find out about digitalWriteFast, do I understand correctly that this only takes one clock cycle?! So at 96MHz it would only be about 10 NANOseconds?! If so, that would simplify things greatly since I would just ignore that time altogether
Just in case you want to see the code from the tutorial that I'm pondering:
Code:
void pulseIR(long microsecs) {
// we'll count down from the number of microseconds we are told to wait
cli(); // this turns off any background interrupts
while (microsecs > 0) {
// 38 kHz is about 13 microseconds high and 13 microseconds low
digitalWrite(IRledPin, HIGH); // this takes about 3 microseconds to happen
delayMicroseconds(10); // hang out for 10 microseconds, you can also change this to 9 if its not working
digitalWrite(IRledPin, LOW); // this also takes about 3 microseconds
delayMicroseconds(10); // hang out for 10 microseconds, you can also change this to 9 if its not working
// so 26 microseconds altogether
microsecs -= 26;
}
sei(); // this turns them back on
}
I know there are Libraries for IR, but I've never used a library before (although I'm working towards using them). I like this tutorial because iit's real down'n'diirty so I can really cut my teeth on what is actually going on. Libraries are great for a good end result, but I need to learn the hard way for experience.
Thanks for your time.