前面我们用了许多延时子程序delay(),称软件延时,虽然能实现了延时,但不能实现分时延时,分时控制是没有办法实现的,并且软件延时程序占用了CPU资源和时间,在实际工作中这样做不恰当。如用软件延时,当主程序实现了灯的闪烁,就不能再做其他工作了,这在实际复杂程序设计中,难以满足要求。
因此,在实际工作中常用定时器中断来实现延时、定时中断控制等类似功能。
Previously, we used many delay subroutines called delay(), also known as software delay. Although it can achieve delay, it cannot achieve time-sharing delay, and time-sharing control cannot be achieved. Moreover, software delay programs occupy CPU resources and time, which is not appropriate in practical work. If software delay is used, when the main program realizes the flashing of the light, no other work can be done, which is difficult to meet the requirements in practical complex program design.
Therefore, timer interrupts are commonly used in practical work to achieve functions such as delay and timed interrupt control.

