# can a timer interrupt a for() routine?

#1

platform:
OpenAT 3.02
GCC
MS Visual C++ 6.0

my aim is to learned the required time to calculate a floating point math function.

#include "adl_global.h"

u16 counter=0;

void sin_TimerHandler ( u8 timerid );

u32 wm_apmCustomStack [ 4096 ];
const u16 wm_apmCustomStackSize = sizeof ( wm_apmCustomStack );

/*************************************************/
{

}

/******************************************************/
{

float lat1 = 6959.458;
float lat2 = 7059.458;
float lon1 = 2727.826;
float lon2 = 2827.826;

float distance=0,distance_total=0;

ascii buffer[100];

u16 i=0,k=0;

distance = ( sin(lat1/57.2958) * sin(lat2/57.2958) ) + ( cos(lat1/57.2958) * cos(lat2/57.2958) * cos(lon2/57.2958 - lon1/57.2958) );

for(i=0;i<100;i++)
{

distance_total += ( sin(lat1/57.2958) * sin(lat2/57.2958) ) + ( cos(lat1/57.2958) * cos(lat2/57.2958) * cos(lon2/57.2958 - lon1/57.2958) );
lat1 += 0.0001;
lat2 += 0.0001;
k=k+1;

}

u32 distan = (u32)(distance);
u32 distan_total = (u32)(distance_total);

wm_sprintf(buffer, "\r\ntime: %d x 18.5 millisecond\r\nlast value of k: %d\r\ndistance: %d \r\ndistance_total: %d ",counter, k,	distan, distan_total);

return TRUE;

}

/***********************************************/
{

counter++;

}

Output is:

according to output code never enter into TICK timer function
but in realtime this calculation lasts more then 2 second ( I measured it after I saw the +WIND: 4 response on Hyp. Term.)
I think something prevents timer function to operate . Is a limitation on this subject?
How can I measure exact time required for any math operation?

#2

No, it cannot!

Your application needs to return control to the operating system in order to get called again. If you do not return from handler functions, the system will not call code in your application.

Best Regards,
Jan