Delay routines are the subroutines used for maintaining the timings of various operations in a microprocessor. In control applications, certain equipment needs to be ON/OFF after a specified time delay. In some applications, a certain operation has to be repeated after a specified time interval. In such cases, simple time delay routines can be used to maintain the timings of the operations.
A delay routine is generally written as a subroutine (It need not be a subroutine always. It can even be a part of the main program .) In a delay routine, a count (number) is loaded in a register of the microprocessor. Then it is decremented by one and the zero flag is checked to verify whether the content of the register is zero or not. This process is continued until the content of the register is zero. When it is zero the time delay is over and the control is transferred to the main program to carry out the desired operation.