Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| learn:microprocessor:tutorials:software-timing-delays:start [2017/12/21 19:37] – Martha | learn:microprocessor:tutorials:software-timing-delays:start [2022/10/04 11:38] (current) – external edit 127.0.0.1 | ||
|---|---|---|---|
| Line 3: | Line 3: | ||
| The purpose of this project is to investigate methods of creating software time delays to pace processor operations. The timing methods that control when a process is to be executed can be implemented by using polling techniques that sample a free running clock or by executing code that requires a fixed amount of time. This project also demonstrates the use of time delays for signal conditioning. | The purpose of this project is to investigate methods of creating software time delays to pace processor operations. The timing methods that control when a process is to be executed can be implemented by using polling techniques that sample a free running clock or by executing code that requires a fixed amount of time. This project also demonstrates the use of time delays for signal conditioning. | ||
| + | |||
| + | \\ | ||
| + | < | ||
| + | <a href="/ | ||
| + | </ | ||
| + | \\ | ||
| + | \\ | ||
| + | < | ||
| + | <a href="/ | ||
| + | </ | ||
| + | \\ | ||
| + | \\ | ||
| + | < | ||
| + | <a href="/ | ||
| + | </ | ||
| + | \\ | ||
| + | \\ | ||
| + | < | ||
| + | <a href="/ | ||
| + | </ | ||
| + | \\ | ||
| + | \\ | ||
| ---- | ---- | ||
| Line 13: | Line 35: | ||
| ==== Inventory ==== | ==== Inventory ==== | ||
| - | * 1 [[http://store.digilentinc.com/ | + | * 1 [[https://digilent.com/shop/ |
| * [[http:// | * [[http:// | ||
| - | * 1 [[http://store.digilentinc.com/ | + | * 1 [[https://digilent.com/shop/ |
| - | * 1 Logic analyzer or oscilloscope (Digilent [[http://store.digilentinc.com/ | + | * 1 Logic analyzer or oscilloscope (Digilent [[https://digilent.com/ |
| ---- | ---- | ||
| Line 61: | Line 83: | ||
| It is sufficient to say that each C instruction can require multiple assembly language instructions to implement and each assembly instruction requires time to execute. The bottom line is that the execution of C code requires time and we can use this time to generate predictable time delays. An alternate method to generate a time delay is to use one of the timer resources of the processor. We will investigate both of these two methods of creating a delay function in this project. | It is sufficient to say that each C instruction can require multiple assembly language instructions to implement and each assembly instruction requires time to execute. The bottom line is that the execution of C code requires time and we can use this time to generate predictable time delays. An alternate method to generate a time delay is to use one of the timer resources of the processor. We will investigate both of these two methods of creating a delay function in this project. | ||
| + | |||
| + | ---- | ||
| ==== Pacing the Computer ==== | ==== Pacing the Computer ==== | ||
| Line 66: | Line 90: | ||
| Two approaches for developing a delay function will be explored in this project. One of them requires no special hardware but instead relies strictly upon the execution time of a software loop. We will refer to this approach as the software delay method. The other uses one of the processor' | Two approaches for developing a delay function will be explored in this project. One of them requires no special hardware but instead relies strictly upon the execution time of a software loop. We will refer to this approach as the software delay method. The other uses one of the processor' | ||
| + | |||
| + | ---- | ||
| ==== Pure Software Delays ==== | ==== Pure Software Delays ==== | ||
| Line 95: | Line 121: | ||
| Given that the “mS” variable that specifies the number of milliseconds to delay is an unsigned integer, the range, or longest possible delay, is 4, | Given that the “mS” variable that specifies the number of milliseconds to delay is an unsigned integer, the range, or longest possible delay, is 4, | ||
| + | |||
| + | ---- | ||
| ==== Calibrating Time for Software Delays ==== | ==== Calibrating Time for Software Delays ==== | ||
| Line 102: | Line 130: | ||
| An effective alternative for measuring delay time is to use the MPLAB X Stopwatch tool described in the third tab on the right. | An effective alternative for measuring delay time is to use the MPLAB X Stopwatch tool described in the third tab on the right. | ||
| + | |||
| + | ---- | ||
| ==== Hardware-Assisted Delays ==== | ==== Hardware-Assisted Delays ==== | ||
| Line 241: | Line 271: | ||
| Figure 1 is an example of the instrumentation to determine the timing for a 20 ms delay. The LEDA trace toggles each 1 ms resulting in a frequency of 500 Hz. The LEDB trace toggles each 20 ms resulting in a frequency of 25 Hz. | Figure 1 is an example of the instrumentation to determine the timing for a 20 ms delay. The LEDA trace toggles each 1 ms resulting in a frequency of 500 Hz. The LEDB trace toggles each 20 ms resulting in a frequency of 25 Hz. | ||
| - | {{ : | + | {{ : |
| Figure 1. Screen capture for 20 ms delay. | Figure 1. Screen capture for 20 ms delay. | ||

