Amit
I think that your measurement method is inaccurate and also has design faults in it.
void RTC1_OnSecond(LDD_TUserData *UserDataPtr)
{
/* Write your code here ... */
printf("loop = %d\n", loop_counter);
loop_counter = 0;
}
You look to be using the RTC seconds interrupt to print out the number of timer interrupts that took place in the last second. Depending on how your RTC clock is derived they may not be synchronised and also may drift form another.
Furthermore PE printf() tends to be a blocking function which will only return when all output characters have been sent. You reset the loop counter in the 1s interrupt after you have sent the value - if the other timer interrupt has higher priority it may still be counting when the printf() output is being sent and so resetting it here may be losing an incermenet (that is - the loop variable may be at 100 (or 400) when used as output value but already be at 101 (or 401) when it is reset (thus losing a count value which will be seen in teh next measurement). If your timers may not be synchroinised I don't think that you can be sure of obtaining an accuracy of better that +0/-1.
I would simply toggle an output in the timer interrupt routine and measure its value with an oscilloscope. This will probably show that it is highly accurate but your output code introduces the errors.
- certainly avoid using printf() in interrupts (especially the PE derived one if it blocks)
- when changing variables in more than 1 interrupt routine be aware of the interrupt routine priorities (can one interrupt the other and cause variable value corruption?)
Regards
Mark