Hi Folks, I am trying to get the NewPingEventTimer example to work on a teensy3.1 using version 1.20 of teensyduino. The NewPingExample code works fine, so I think my hookup is OK. Also, the teensy IntervalTimer example works fine (blinking an led), so the timers seem OK. I have looked at the library, and it seems it should work. I have run the examples on an Uno, and they all work fine, so my SR04 seems OK. I commented out the printing in the echoCheck routine and just set a variable there, but it never changes. It appears that the echoCheck routine is being invoked, but the check_timer test is never passing. Any clues about running this down would be appreciated.
Thanks, Duane
UPDATE: After dinking a bit with the NewPing examples, I finally changed the library NewPing.cpp like this:
elif defined(__arm__) && defined(TEENSYDUINO)
itimer.begin(userFunc, frequency);
// itimer.begin(userFunc, (float)1000000.0 / (float)frequency);
In other words, I called itimer.begin() passing the frequency value directly since it is specified in microseconds. I also changed the Serial.print foo in the echoCheck() routine in the example to just set a value. The printing works fine on an Arduino, but does not seem to work on a teensy3. It seems questionable to call something like Serial.print from an interrupt routine anyway. Now it seems to work -- nota bene:I have not carefully checked the accuracy of the measurement. I can post my version of the example if anyone is interested. My next step will be to try to use an input capture on the echo pin since that seems a more elegant way to do this, and I need to learn how to use this chip anyway.