I am using the C8051F931 and have been setting up the SmaRTClock with the submitted example code in SmartClock.c, RTC_Init: This is a snippet of the RTC_Init():
RTC_Write (RTC0CN, 0xC0); // Enable missing smaRTClock detector
// and leave smaRTClock oscillator
// Wait > 2 ms
for (i=0x340; i!=0; i--);
RTC_Write (RTC0CN, 0xC0); // Clear the clock fail flag (precautionary).
The comment says "Wait > 2 ms", and indeed it does, but if I measured it correctly on the scope, it is way longer, more like 50ms. I figured that the loop takes ~8-11 machine cycles and the example code is using the 156 kHz LP oscillator, which gives a similar result of roughly 40-60ms
So, if I am correct, why is it longer than needed, and could I trust the "> 2ms" info and reduce the delay?
That code was likely written for the worst case scenario of running with the internal precision oscillator at full speed. You may reduce the delay down to 2 ms if you know what clock speed you will always be at when you reach that line.
The delay also highly depends on how much optimization the compiler can achieve.