danh cho nguoi moi tim hieu 8051
Cac anh oi tiep tuc huong dan tiep cho tui em ve nut nhan va LCD di ma.Tui em doi lau qua,nhan tien cho em hoi doan code sau cai nao thi toi uu hon va do ton ram hon:
//======================
void delay (unsigned int ms)
{
while(ms--) //ms nhap la1000 de co dc 1S
{
TMOD=0x01;
TH0=0xFC;
TL0=0x18;
TR0=1;
while(!TF0);
TR0=0;
TF0=0;
}
}
//=======va doan code nay
void delay(unsigned char ms)
{
while(ms--) //NHAP LA 20 de co duoc 1 s
{
TMOD=0x01;
TH0=50000;
TL0=50000;
TR0=1;
while(!TF0);
TR0=0;
TF0=0;
}
}
Cac anh oi tiep tuc huong dan tiep cho tui em ve nut nhan va LCD di ma.Tui em doi lau qua,nhan tien cho em hoi doan code sau cai nao thi toi uu hon va do ton ram hon:
//======================
void delay (unsigned int ms)
{
while(ms--) //ms nhap la1000 de co dc 1S
{
TMOD=0x01;
TH0=0xFC;
TL0=0x18;
TR0=1;
while(!TF0);
TR0=0;
TF0=0;
}
}
//=======va doan code nay
void delay(unsigned char ms)
{
while(ms--) //NHAP LA 20 de co duoc 1 s
{
TMOD=0x01;
TH0=50000;
TL0=50000;
TR0=1;
while(!TF0);
TR0=0;
TF0=0;
}
}
Comment