delay.h

Description:

    This header file generates time delay in the form of mili second and micro second
    without affecting any interrupts.

Functions:

    delayms();          This function provides delay in the form of mili second
    delayus();          This function provides delay in the form of micro second

#ifndef <DELAY.H>
#define <DELAY.H>

unsigned int delaycounter1,delaycounter2;

void delayms(unsigned int delaytime)
{
    for(delaycounter1=0;delaycounter1<=delaytime;delaycounter1++)
    {
        for(delaycounter2=0;delaycounter2<=800;delaycounter2++)
        {
            asm(“nop”);asm(“nop”);asm(“nop”);asm(“nop”);asm(“nop”);asm(“nop”);
            asm(“nop”);asm(“nop”);asm(“nop”);asm(“nop”);asm(“nop”);asm(“nop”);
        }
    }
}

void delayus(unsigned int delaytime)
{
    for(delaycounter1=0;delaycounter1<=delaytime;delaycounter1++)
    {
        asm(“nop”);asm(“nop”);asm(“nop”);asm(“nop”);asm(“nop”);asm(“nop”);
        asm(“nop”);asm(“nop”);asm(“nop”);asm(“nop”);
    }
}

#endif

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s