STC51几种简单的延时函数

STC51几种简单的延时函数

 

1,*  延时子程序                                                                 *

*                                                                             *

******************************************************************************/

void delayms(unsigned char ms)

{

    unsigned char i;

    while(ms--)

    {

    for(i = 0; i < 120; i++);

    }

}



*********************************************

2.

void delay(unsigned int i)

{

    char j;

    for(i; i > 0; i--)

        for(j = 200; j > 0; j--);

}

3.

void delayms(uint xms)

{

    uint i, j;

    for(i=xms; i > 0; i--)

        for(j = 120; j > 0; j--);

}



***************************************************************

4.

void delay11us(uint z)

{

        uint a,b;

    for(a=11;a>0;a--)

            for(b=z;b>0;b--);

}

***************************************************************

5void delayms(int m)

{

    int i,j;

    for(i=0;i<m;i++)

    {

        for(j=0;j<12;j++)

        {}

    }

}

 

你可能感兴趣的:(函数)