Time Delays in 8051 C
We can create time delay in 8051 C by two ways:
Using for loop statement
. Using the 8051 timers
We cannot get the exact delays using simple for loops because of following reasons:
1. The instruction execution speed varies according to the number of clock periods per machine cycle. The different variants of 8051 microcontroller use different clock periods per machine cycle.
2. The crystal frequency connected to the X₁-X₂ input pins. The duration of the clock period for the machine cycle is a function of this crystal frequency.
3. In case of C programs, it is the C compiler that converts the C statements and functions to assembly language instructions. As a result different compilers produce different code and hence instructions executed in a loop may vary with different compilers.
Comments
Post a Comment