Pass templated function as attachInterrupt parameter
Try this:

template&lt;int PIN, int CHANNEL&gt; void initPin() {
    attachInterrupt(PIN, rising&lt;PIN, CHANNEL&gt;, RISING);
}


template&lt;int PIN, int CHANNEL&gt; void rising() {
    startTimes[CHANNEL] = micros();
    attachInterrupt(PIN, falling&lt;PIN, CHANNEL&gt;, FALLING);
}

template&lt;int PIN, int CHANNEL&gt; void falling() {
    values[CHANNEL] = micros() - startTimes[CHANNEL];
    attachInterrupt(PIN, rising&lt;PIN, CHANNEL&gt;, RISING);
}


The problem is actually the Arduino preprocessor. It adds illegal forward declarations if template functions are formated as your original code.