Đây là bài lập trình các bác xem hộ em sao toàn bị lội như sau:
//===========================================
Build target 'Target 1'
compiling dongholoade1-8.c...
DONGHOLOADE1-8.C(93): error C202: 'd': undefined identifier
DONGHOLOADE1-8.C(94): error C202: 'd': undefined identifier
Target not created
//===========================================
//*******LCD code -created by DOAN VU**************
//******KHI LAP TRINH ,DONG HO SO+LOA+CHINH GIO 24/7/2012******************
#include <regx51.h>
#include <E:\LAP TRINHC CHO 8051\THU VIEN\THU VIEN DELAY.h>
#include <E:\LAP TRINHC CHO 8051\THU VIEN\THU VIEN LCD.h>
//-------------------------------------------------
unsigned int x=0;
unsigned int y=0;
unsigned int z=0;
unsigned int count;
//---------------CHUONG TRINH CON------------------
void hienthi(void)
{
lcd_gottoxy(10,0);
lcd_putchar(x/10+48);
lcd_putchar(x%10+48);
lcd_gottoxy(9,0);
lcd_putchar(':');
lcd_gottoxy(7,0);
lcd_putchar(y/10+48);
lcd_putchar(y%10+48);
lcd_gottoxy(6,0);
lcd_putchar(':');
lcd_gottoxy(4,0);
lcd_putchar(z/10+48);
lcd_putchar(z%10+48);
}
//--------------------
void timer1(void) interrupt 3 using 2
{
TH1=0xd8;
TL1=0xf0;
TR1=1;
count++;
if(count>=100){count=0;x++;}
if(x>=60) { x=0; y++;}
if(y>=60) { y=0; z++;}
if(z>=24) { z=0;}
}
//-----------------------------------------
void nhaycham()
{
if( count>50)
{
lcd_gottoxy(9,0);
lcd_putchar(':');
lcd_gottoxy(6,0);
lcd_putchar(':');
}
else
{
lcd_gottoxy(9,0);
lcd_putchar(' ');
lcd_gottoxy(6,0);
lcd_putchar(' ');
}
}
void chinhgio()
{
if(P3_0==0){ y++; while(P3_0==0){};}
if(y>=60){y=0;}
if(P3_1==0){ z++;while(P3_1==0){};}
if(z>=24){z=0;}
if(P3_2==0){ TR1=0;}
if(P3_3==0){TR1=1;}
}
//================================================== ====
void tinhtoan()
{
unsigned int a,d;
const unsigned int mang[10]={395,395,395,525,395,395,395,395}; //==mang tan so cua am thanh
for(a=0;a<8;a++)
{
d=mang[a];
}
}
//=================================================
void timer0(void) interrupt 1 using 2
{
TH0= ((65536-(1000000/(d*2)))%256);//cach tinh ra he 10
TL0= ((65536-(1000000/(d*2)))/256);
TR0=1;
P3_7=~P3_7 ;
}
//-------------CHUONG TRINH -----------------------
void main(void)
{
TMOD=TMOD|0x11;
TH1=0x00;
TL1=0x10;
ET1=1;
EA=1;
TR1=1;
lcd_init();
TH0=0x00;
TL0=0x10;
ET0=1;
EA=1;
TR0=1;
lcd_init();
while(1)
{
hienthi();
nhaycham();
chinhgio();
tinhtoan();
}
}
////////////////////////////////////
// A LA
// B SI
// C DO
// D RE
// E MI
// F PHA
// G SON
//===========================================
Build target 'Target 1'
compiling dongholoade1-8.c...
DONGHOLOADE1-8.C(93): error C202: 'd': undefined identifier
DONGHOLOADE1-8.C(94): error C202: 'd': undefined identifier
Target not created
//===========================================
//*******LCD code -created by DOAN VU**************
//******KHI LAP TRINH ,DONG HO SO+LOA+CHINH GIO 24/7/2012******************
#include <regx51.h>
#include <E:\LAP TRINHC CHO 8051\THU VIEN\THU VIEN DELAY.h>
#include <E:\LAP TRINHC CHO 8051\THU VIEN\THU VIEN LCD.h>
//-------------------------------------------------
unsigned int x=0;
unsigned int y=0;
unsigned int z=0;
unsigned int count;
//---------------CHUONG TRINH CON------------------
void hienthi(void)
{
lcd_gottoxy(10,0);
lcd_putchar(x/10+48);
lcd_putchar(x%10+48);
lcd_gottoxy(9,0);
lcd_putchar(':');
lcd_gottoxy(7,0);
lcd_putchar(y/10+48);
lcd_putchar(y%10+48);
lcd_gottoxy(6,0);
lcd_putchar(':');
lcd_gottoxy(4,0);
lcd_putchar(z/10+48);
lcd_putchar(z%10+48);
}
//--------------------
void timer1(void) interrupt 3 using 2
{
TH1=0xd8;
TL1=0xf0;
TR1=1;
count++;
if(count>=100){count=0;x++;}
if(x>=60) { x=0; y++;}
if(y>=60) { y=0; z++;}
if(z>=24) { z=0;}
}
//-----------------------------------------
void nhaycham()
{
if( count>50)
{
lcd_gottoxy(9,0);
lcd_putchar(':');
lcd_gottoxy(6,0);
lcd_putchar(':');
}
else
{
lcd_gottoxy(9,0);
lcd_putchar(' ');
lcd_gottoxy(6,0);
lcd_putchar(' ');
}
}
void chinhgio()
{
if(P3_0==0){ y++; while(P3_0==0){};}
if(y>=60){y=0;}
if(P3_1==0){ z++;while(P3_1==0){};}
if(z>=24){z=0;}
if(P3_2==0){ TR1=0;}
if(P3_3==0){TR1=1;}
}
//================================================== ====
void tinhtoan()
{
unsigned int a,d;
const unsigned int mang[10]={395,395,395,525,395,395,395,395}; //==mang tan so cua am thanh
for(a=0;a<8;a++)
{
d=mang[a];
}
}
//=================================================
void timer0(void) interrupt 1 using 2
{
TH0= ((65536-(1000000/(d*2)))%256);//cach tinh ra he 10
TL0= ((65536-(1000000/(d*2)))/256);
TR0=1;
P3_7=~P3_7 ;
}
//-------------CHUONG TRINH -----------------------
void main(void)
{
TMOD=TMOD|0x11;
TH1=0x00;
TL1=0x10;
ET1=1;
EA=1;
TR1=1;
lcd_init();
TH0=0x00;
TL0=0x10;
ET0=1;
EA=1;
TR0=1;
lcd_init();
while(1)
{
hienthi();
nhaycham();
chinhgio();
tinhtoan();
}
}
////////////////////////////////////
// A LA
// B SI
// C DO
// D RE
// E MI
// F PHA
// G SON
Comment