單片機中時延函數(shù)易常范的錯誤
#include
#include
sbit wr = P3^6;
sbit rd = P3^7;
sbit dula = P2^6;
sbit wela = P2^7;
unsigned char j,k,aa;
void delay(unsigned char i)
{
for(j=i;j>0;j--)
for(k=125;k>0;k--);
}
void main()
{
unsigned char a;
while(1)
{
wela = 1;
P0 = 0;
wr = 0;
_nop_();
wr = 1;
delay(10);
//
delay(255); //轉(zhuǎn)換等待
rd = 0;
}
}
【注釋】此代碼在TX-1C中通過
評論