延时函数是延时时间怎么计算的,一下面的延时请大神讲解讲解,谢谢。
#include <intrins.h>#include <STC_NEW_8051.H>
#include "EEPROM.c"
typedef unsigned char U8; /* defined for unsigned 8-bits integer variable 无符号8位整型变量 */
typedef signed char S8; /* defined for signed 8-bits integer variable 有符号8位整型变量 */
typedef unsigned int U16; /* defined for unsigned 16-bits integer variable 无符号16位整型变量 */
typedef signed int S16; /* defined for signed 16-bits integer variable 有符号16位整型变量 */
typedef unsigned long U32; /* defined for unsigned 32-bits integer variable 无符号32位整型变量 */
typedef signed long S32; /* defined for signed 32-bits integer variable 有符号32位整型变量 */
typedef float F32; /* single precision floating point variable (32bits) 单精度浮点数(32位长度) */
typedef double F64; /* double precision floating point variable (64bits) 双精度浮点数(64位长度) */
//U8 code cb1[42]={0,0,1,2,3,5,7,9,11,13,16,19,22,26,30,34,38,42,46,51,56,61,67,72,77,83,90,100,110,120,130,140,150,160,175,190,205,220,235,250,255,255};
//U8 code cb2[42]={255,255,254,253,252,250,248,246,244,242,239,236,233,229,225,221,217,213,209,204,199,194,188,184,178,172,165,155,145,135,125,115,105,95,80,65,50,35,20,5,0,0};
sbit A2=P3^3;
sbit A1= P3^5;
sbit k1 = P3^4;
sbit k2 = P3^0;
sbit k3 = P3^2;
sbit k4 = P3^1;
U8 bdata D;
sbit K1=D^0;
sbit K2=D^1;
sbit K3=D^2;
sbit K4=D^3;
U8 Byte_Read(U16 add);
void ioout(void)
{
k1=K1;
k2=K2;
k3=K3;
k4=K4;
}
void Delay100ms() //@11.0592MHz
{
unsigned char i, j, k;
_nop_();
_nop_();
i = 5;
j = 52;
k = 195;
do
{
do
{
while (--k);
} while (--j);
} while (--i);
}
void Delay1s(U8 s)
{
U8 m,n;
for(m=s;m>0;m--)
for(n=10;n>0;n--)
Delay100ms();
}
void pao(U8 io)
{
D=io;
ioout();
Delay1s(10);
}
void main(void)
{
P3M0=0X17;
/// INT_CLKO=0X20; //允许外部中断3.
// IT1=1; //外部中断1,下降沿中断。
// EX1=1; //允许1中断。
// EA=1;
while(1)
{
pao(0);
pao(1);
}