You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
31 lines
825 B
31 lines
825 B
#include "TeensyTimerTool.h"
|
|
using namespace TeensyTimerTool;
|
|
|
|
|
|
|
|
//Timer t[]{FTM0, FTM0, FTM2}; // two channels from FTM0, one from FTM2
|
|
//Timer t[3]; // use 3 timers from the pool
|
|
OneShotTimer t[]{FTM0, FTM0, FTM0, FTM0, FTM0, FTM0, FTM0, FTM0}; // all 8 channels of FTM0
|
|
|
|
constexpr unsigned nrOfTimers = sizeof(t) / sizeof(t[0]);
|
|
|
|
void setup()
|
|
{
|
|
// setup timers, use lambdas as callbacks
|
|
for (unsigned i = 0; i < nrOfTimers; i++)
|
|
{
|
|
pinMode(i, OUTPUT);
|
|
t[i].begin([i] { digitalWriteFast(i, LOW); }); // callback resets pin to LOW
|
|
}
|
|
}
|
|
|
|
|
|
void loop()
|
|
{
|
|
for (unsigned i = 0; i < nrOfTimers; i++)
|
|
{
|
|
digitalWriteFast(i, HIGH);
|
|
t[i].trigger(50 * (i + 1)); // 50, 100, 150 ... µs
|
|
}
|
|
delay(1);
|
|
}
|
|
|