I'm currently trying to drive a stepper controller at 90KHz. I also need to ramp-up and down the speed. I tried earlier with an Arduino but was VERY limited in terms of speed. With the maple I can just use timer interrupts to generate the signal.
What I'd like is to get some validation of my approach before investing too much time in it. I currently set up two timers, one which generates the ticks for stepping, another at a fixed frequency that adjusts the frequency of the first one:
timer.setPrescaleFactor( 1 ); //72MHz
timer.setOverflow( 791 ); //90.907 KHz
timer.setChannel1Mode( TIMER_OUTPUT_COMPARE );
timer.setCompare( TIMER_CH1, 1 );
timer.attachCompare1Interrupt( handler );
ramp.setPeriod( 1000 ); //1ms
ramp.setChannel1Mode( TIMER_OUTPUT_COMPARE );
ramp.setCompare( TIMER_CH1, 1 );
ramp.attachCompare1Interrupt( ramp_handler );
Now in handler() I just generate a pulse on the step pin and increment a global step counter so I can know when to stop, and in ramp_handler() I change timer.setOverflow() from 65535 to 791 to accelerate, and the inverse to decelerate.
Does that approach make any sense? Is there a better way of doing this?