Creating “software delays”


How do you create a simple delay without using any hardware
(timer) resources?

Solution

Loop_Delay()


{
unsigned int x,y;
for (x=0; x <= 65535; x++)
{
y++;
}
}
Longer_Loop_Delay()
{
unsigned int x, y, z;
for (x=0; x<=65535; x++)
{
for (y=0; y<=65535; y++);
{
z++;
}
}
}