I wanted to time something properly using the root counters but I'm having problems getting the results I want.
According to the documentation (Run-Time Library Overview):
-RCntCNT1 System clock
-RCntCNT2 System clock (8 cycles)
One tick is approximately equal to 0.03 microseconds when counting by the system clock. In the 8-cycle
mode, 1 tick equals 8 times .03 microseconds (approximately .24 microseconds).
Then I do this:
Code: Select all
int main()
{
SetRCnt(RCntCNT1, 65000, RCntMdINTR);
StartRCnt(RCntCNT1);
while (1)
if (GetRCnt(RCntCNT1) >= 15000)
{
printf("Here is a second\n");
ResetRCnt(RCntCNT1);
StartRCnt(RCntCNT1);
}
}
Note 15000 does not return an exact second but should be close to this number. Also, I'm running this in NO$Cash, not sure if that's relevant.
What am I doing wrong or what am I missing?
Thanks!