TimerOne is a compatibility wrapper around the native IntervalTimer. So, unless you need to write code compatible to AVR you'd be better of with an IntervalTimer. This code generates a 50µs pulse every 1000µs:
Code:
constexpr int PIN_DEBUG = 6;
void timerInterrupt()
{
digitalWriteFast(PIN_DEBUG, HIGH);
delayMicroseconds(50); // Small delay so the pulse shows up on the oscilloscope
digitalWriteFast(PIN_DEBUG, LOW);
}
IntervalTimer t;
void setup()
{
pinMode(PIN_DEBUG, OUTPUT);
digitalWriteFast(PIN_DEBUG, HIGH); // Pulse to indicate the timer start time.
delayMicroseconds(50);
digitalWriteFast(PIN_DEBUG, LOW);
t.begin(timerInterrupt, 1000);
}
void loop() {}
(My ultimate goal is to read serial data from an input, using timer interrupts to sample the data in the middle of a pulse, and restarting the timing on a signal edge. But the time intervals are half of what I specify. The code above is simplified to show the problem, so it's not actually useful.)
You might be interested to use the TeensyTimerTool for this. Here an example which generates a 50µs pulse 1ms after a rising edge on the signal input pin. For testing it generates a 100Hz signal on pin 0. I connected this pin to the signal pin.
Code:
#include "TeensyTimerTool.h"
using namespace TeensyTimerTool;
constexpr unsigned pin_debug = 6;
constexpr unsigned pin_signal = 14;
OneShotTimer timer(TCK); // use a software timer (TCK) here, to avoid the usual interrupt difficulties.
void onTimer()
{
digitalWriteFast(pin_debug, HIGH);
delayMicroseconds(50); // Small delay so the pulse shows up on the oscilloscope
digitalWriteFast(pin_debug, LOW);
// do your stuff here
}
void onEdgeReceived()
{
timer.trigger(1000); // trigger the one shot timer whenever you detect an edge on pin_signal
}
void setup()
{
pinMode(pin_debug, OUTPUT);
pinMode(pin_signal, INPUT_PULLDOWN);
pinMode(0, OUTPUT);
timer.begin(onTimer); // intialize timer and attach the onTimer callback to it
attachInterrupt(pin_signal, onEdgeReceived, RISING); // call onEdgeReceived on a rising edge on pin_signal
// for testing only
analogWriteFrequency(0, 100); // generate a 10Hz signal on pin 0, connect to pin_signal for testing
analogWrite(0, 128);
}
void loop()
{
}
LA Output:

Hope I understood your goal correctly....