I would do this sort of thing repetitively with a HC08 in an engine ECU, measuring rpm and doing things accordingly. Why is something so simple now so hard???
TIMER_STUFF BRSET TOF,TSC,VERYTOP_X ;super slow! = 1.048560 sec, 28.6 rpm 4 cyl
LDHX TCNTH ;grab timer
BSET TRST,TSC ;reset timer
BCLR TOF,TSC ;reset overflow if set
STHX TBS_MSB ;for offtime calc
STHX TBSDIV8_MSB ;for excess dwell calc
STHX STEP_MSB ;for excess dwell step size
CPHX #6250 ;go back to cranking mode
BHI VERYTOP_X ;if < 300 rpm 4 cyl