Perhaps I do not wholly understand your purpose, but why is it necessary to use a timer for the display? It seems (from what I understand of your intent) that something like the pseudo-code below would suffice:
I would not question, but it seems at the very slow RPM you are measuring, the frequency of updating the display will happen many times and is not nearly so critical... It will take relatively many iterations before there is new information to display and there is no benefit (as I see it) to worry so long as the loop executes fast enough to avoid flicker. It seems, if I understand you correctly, that each rotation interrupt is a full rotation and yields new RPM data or am I mistaken?Code:Set up interrupt on complete rotation Set up interrupt on Timer1 overflow RPM = 0 Main: If (button pushed) and (Flag = 0) enable interrupts and Flag = 1 if (button pushed) and (Flag = 1) disable interrupts and Flag = 0 For Digit = 1 to 3 'multiplex display PORTA.Digit = 1 Lookup . . . PortA.Digit = 0 Next Digit XXXXXXX 'No pause here, it slows interrupts Goto Main On Timer1 Overflow: Timer1Overflows = Timer1Overflows + 1 'Timer0 may be used here, but will result in a higher multiplier Resume On rotation interrupt: RPM = Timer1Overflows * [Time to Overflow] + [Timer1 current value in mSecs]... 'Calculate new RPM Timer1Overflows reset : Timer1 reset Resume





Bookmarks