Software delays
In this section:
A software delay might be implemented as a for or while loop like for example:
i = 10000; /* A software delay */ do iāā; while (i != 0);
Such software delays will keep the CPU busy with executing instructions performing nothing except to make the time go by. Time delays are much better implemented using a hardware timer. The timer interrupt is set up and after that, the CPU goes down into a low power mode until it is awakened by the interrupt.