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;
adl_tmr_t * timer_timerHandle;
adl_tmr_t * TICK_timerHandle;
s16 Wind4_Handler(adl_atUnSoHandler_t *paras);
void timer_adl_tmrHandler_t(u8 timerid);
void sin_TimerHandler ( u8 timerid );
void TICK_adl_tmrHandler_t(u8 timerid);
u32 wm_apmCustomStack [ 4096 ];
const u16 wm_apmCustomStackSize = sizeof ( wm_apmCustomStack );
/*************************************************/
void adl_main ( adl_InitType_e InitType )
{
adl_atSendResponse ( ADL_AT_UNS, "\r\nI am in main\r\n" );
adl_atUnSoSubscribe( "+WIND: 4", (adl_atUnSoHandler_t)Wind4_Handler);
}
/******************************************************/
s16 Wind4_Handler(adl_atUnSoHandler_t *paras)
{
adl_atSendResponse ( ADL_AT_UNS, "\r\nsine cosine calculation\r\n" );
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;
TICK_timerHandle = adl_tmrSubscribe( TRUE, 1, ADL_TMR_TYPE_TICK , TICK_adl_tmrHandler_t );
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);
adl_atSendResponse ( ADL_AT_UNS, buffer );
adl_tmrUnSubscribe( TICK_timerHandle, TICK_adl_tmrHandler_t, ADL_TMR_TYPE_TICK );
return TRUE;
}
/***********************************************/
void TICK_adl_tmrHandler_t(u8 timerid)
{
adl_atSendResponse ( ADL_AT_UNS, "\r\nin TICKer" );
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?
Thanks in advance