program wont cooperate (MS_Timer)

I’m having trouble using the MS_TIMER and getting a reliable output. If I capture the output and store it in a variable then capture another event on milliseconds apart I get a lot more Msecs than I would expect. For example,
Timer1 would be 2449 and timer2 would be 16889, this is what would happen if I pressed the buttons with only a few milliseconds gap.

Any ideas???

This code should compile and run with the demo board.

This program uses the BL1800 and the demo board. I use buttons s1 and s2 for the inputs. I am testing a program that will
test two sensors on a highway that monitor speed, they are 11’ apart. If a car goes 125ms in that 11’ then that should be
around 60mph. I want to capture the MS_TIMER at the close of button1 and the close of button2 then subtract to get my
total time.

#class auto
void main()
short flag;
unsigned long timer1, timer2;
float factor;

flag = 1;

while (1)
if(BitRdPortI(PBDR, 2)) abort; //Abort if button not pressed.
timer1 = MS_TIMER; //Capture MS_TIMER at this time.
flag = 0; //Set loop repeat flag to 0.
waitfor(flag); //Don’t let costate repeat until second costate finishes.

  	if((!BitRdPortI(PBDR, 2))&& (!BitRdPortI(PBDR, 3))&& flag == 0)   //If button1 and button2 pressed do this.
     	timer2 = MS_TIMER;                                 //Capture MS_TIMER at this time
     	timer2 -= timer1;                                  //Subtract timer2 from timer1 to get total time in MSec.
     	factor = (float)11/timer2;                         //ex. 11/125 is 11feet/125ms should = about 60mph. So
    		printf("Timer= %3.0f

", (float)factor*682); // (11/125)*682 should be 60.
flag = 1; //Set flag so that the process can repeat.
waitfor(BitRdPortI(PBDR, 3)); //Wait for the button to release