ok exactly 12mhz = 3 mhz internal clock:
1/3Mhz = 3.333333333333333e-7 = 0.0000003333333333333333
which is 0.0000003333333333333333 aka 333.3333333333333ns each cycle
1 second = 1 / 333.3333333333333ns = 3000000.0003= 3,000,000 Cycles... and yes its correct... check out this link:
To Calc it on the fly make some functions like ...
1 second = 3,000,000 cycles
1 millisecond = 3,000 cycles
1 microsecond = 3 cycles
Make loops for each like:
Code:
void delay_ms(int time)
{
int i;
for (i=0;i<time;i++)
_delay(30000);
}
Now you can delay 10 ms with : delay_ms(10);
Be aware it wont be 100% accurate since you have to calculate how long it takes to make the call to the function... how long it takes for 1 loop and then to leave the function. But if 1ms off is ok im sure this will do