Aaron2
Junior Member level 3
- Joined
- Nov 20, 2013
- Messages
- 28
- Helped
- 0
- Reputation
- 0
- Reaction score
- 0
- Trophy points
- 1,281
- Activity points
- 1,471
Understanding a Delay, for(j=0;j<1275;j++);, Crystal freq & 1275, 8051
I see countless uses of this basic Delay, usually for milliseconds.
I have not been able to find a good explanation (formula) of how the 1275 is derived, I'm pretty sure its a function of crystal frequency and clock cycles to execute a command. My projects use a 11.0952 and 12.0 mhz crystals.
Any advice or links appreciated.
Found it.
https://www.engineersgarage.com/forums/8051/1-ms-delay-calculation
I see countless uses of this basic Delay, usually for milliseconds.
Code:
void delay(int ms) //Produces a delay in msec.
{
int i,j;
for(i=0;i<ms;i++)
for(j=0;j<1275;j++);
}
I have not been able to find a good explanation (formula) of how the 1275 is derived, I'm pretty sure its a function of crystal frequency and clock cycles to execute a command. My projects use a 11.0952 and 12.0 mhz crystals.
Any advice or links appreciated.
Found it.
https://www.engineersgarage.com/forums/8051/1-ms-delay-calculation