The formula for calculating the number of loops needed to create a desired time delay is:
N = (T * F) / E
where:
- N is the number of loops
- T is the desired time delay in milliseconds
- F is the clock frequency in megahertz
- E is the number of E-cycles per loop
In this case, we have:
- T = 130 ms
- F = 20 MHz
- E = 150
Plugging these values into the formula, we get:
N = (130 ms * 20 MHz) / 150 = 193 loops
Therefore, we need to execute 193 loops to create a 130 ms time delay.
Here is the detailed process of the calculation:
- First, we convert the desired time delay from milliseconds to seconds. To do this, we divide the time delay by 1000: 130 ms / 1000 = 0.13 s
- Next, we multiply the time delay in seconds by the clock frequency in megahertz to get the number of clock cycles: 0.13 s * 20 MHz = 2.6 MHz
- Finally, we divide the number of clock cycles by the number of E-cycles per loop to get the number of loops: 2.6 MHz / 150 = 193 loops
Therefore, we need to execute 193 loops to create a 130 ms time delay.