使用 TimerTree 的 Teensy 4.x 定时器中断示例

teensy_timer_interrupt.cpp
void myTimerInterrupt() {
  // TODO 你的代码放在这里
  // 以下函数可能在此有用:
  // Timer3.start(); // 开始计数并清除计数器
  // Timer3.stop(); // => 停止计数但不清除计数器
  // Timer3.restart(); // => 清除计数器
  // Timer3.resume(); // => 开始,不清除计数器
}

void setup()
{
  Timer3.initialize(20000);
  Timer3.attachInterrupt(myTimerInterrupt);
  Timer3.start();
}

Check out similar posts by category: Arduino, Electronics, Embedded, Teensy