My current code looks like this:
static const int ISR_STEPS = 14;
static int currentIsrStep = 0;
ISR(TIMER1_OVF_vect) {
switch (currentIsrStep) {
case 0:
// do first part of the LED matrix update code
break;
case 1:
// second part of the LED matrix update code
break;
[...]
case 9:
...
break;
case 10:
...
break;
}
currentIsrStep++;
if (currentIsrStep == ISR_STEPS) {
currentIsrStep = 0;
}
}
Steps 0-10 are each calling parts of the code needed to update the LED matrix - steps 11-13 are doing nothing so that the entire update code is running as close as possible at the beginning of my original ~1250us interval.
Instead of having a fixed interrupt call rate I'd like to set at the end of every interrupt method call the duration until the TIMER1 will again call the interrupt method. If I would be able to query somehow if the serial interrupt has to do some work than this would be a plus.
Greetings,
Markus