|
Tài trợ cho PIC Vietnam |
Lỗi lập trình ngôn ngữ cấp cao Những lỗi trường gặp trong lập trình. Khóa luồng khi bug được lỗi. |
|
Ðiều Chỉnh | Xếp Bài |
10-07-2009, 08:22 PM | #1 |
Nhập môn đệ tử
Tham gia ngày: Feb 2009
Bài gửi: 6
: |
Lỗi khi Compile sang file HEX
//CHUONG TRINH HIEN TAI CAC NUT CHUC NANG CHUA HOAT DONG
//XEM LAI CLEAR KHONG THE //KHONG THE GIAU SO DA NHAP #include <16f877a.h> #fuses NOWDT,XT,NOPROTECT,NOLVP,PUT #use delay(clock=4000000) #include <lcd.c> #use fast_io(b) #byte portB=0x06 #use fast_io(b) #byte portc=0x07 #use fast_io(b) #byte portD=0x08 #use fast_io(b) #byte portE=0x09 #bit RS = portE.2 #bit RW = portE.1 #bit E = portE.0 #bit c0=portc.0 #bit c1=portc.1 #define LCD PortB const unsigned char dig[]= {'M','O','I',' ','N','H','A','P',' ','P','A','S','S',':','#'}; int8 i,j,a=0; int8 nhap_mk(); void dat_mk(); void tao_mk_moi(); void enter(); int8 mk; int8 ch; void command() { RS = 0; //ghi lenh RW = 0; E = 1; E = 0; delay_ms(6); } void display() { RS = 1;//ghi du lieu RW = 0; E = 1; E = 0; delay_ms(6); } //**********kiem tra mat khau*************** void kt_mk() { int8 kt; if(c0==0) { delay_ms(50); if (c0 == 0) { kt = read_eeprom(0x00); if (kt == 0) dat_mk(); else tao_mk_moi(); } } if(c1 == 0) { delay_ms(50); if(c1 == 0) enter(); } } //******************************************** void dat_mk() { lcd_gotoxy(0, 1); lcd_putc("hap mb"); delay_ms(100); mk = nhap_mk(); write_eeprom(0x00, mk); delay_ms(10); lcd_gotoxy(10, 1); lcd_putc("ghi hoan tat"); } //*********************tao mk moi void tao_mk_moi() { lcd_gotoxy(2, 1); lcd_putc("mk cu"); delay_ms(100); mk = nhap_mk(); if(mk == read_eeprom(0x00)) { delay_ms(10); lcd_gotoxy(4, 1); lcd_putc("mk moi"); delay_ms(100); mk = nhap_mk(); write_eeprom(0x00, mk); lcd_gotoxy(11, 1); lcd_putc("ghi hoan tat"); delay_ms(100); } else { lcd_gotoxy(7, 1); lcd_putc("sai ma"); delay_ms(100); } } //********************enter************* void enter() { lcd_gotoxy(3, 1); lcd_putc("Password??"); delay_ms(100); mk = nhap_mk(); if(mk == read_eeprom(0x00)) { lcd_gotoxy(4, 1); lcd_putc("You're welcom"); delay_ms(100); } else { lcd_gotoxy(7, 1); lcd_putc("Wrong pass!"); delay_ms(100); } } //***********ghi eeprom********* void ghi_eeprom(int8 ch) { write_eeprom(0x00, ch); } //********************************* int8 doc_eeprom() { int8 ch; ch = read_eeprom(0x00); return ch; } //******************************************** void main() { Set_tris_B(0); Set_tris_E(0); delay_ms(100); //thoi gian de LCD hien thi LCD = 0x38; //Hai hang, ma tran 5x7, b bit command(); LCD = 0x0C; //Bat hien thi, tat con tro command(); LCD = 0x80; //Vi tri hang 1, cot ?; Ve dau dong 1 command(); //---------------------------------------- //---------------------------------------- While(dig[a]!='#') { portB=dig[a]; display(); delay_ms(100); a++; } output_b(0xC0); //Ve dau dong 2 command(); delay_ms(100); output_d(0b11111111); while(1) { int8 nhap_mk() { int8 mk; //*************************************** //*************************************** output_d(0b01111111); //Hang 0 chan RD7 xuong muc 0 delay_ms(10); if(input(pin_D3)==0) //cho D3 xuong muc 0 mk = 0x10; { output_b('A'); //ghi A display(); delay_ms(150); } if(input(pin_D2)==0) //cho D2 xuong muc 0 mk = 0x00; { output_b(0x30); //ghi 0 display(); delay_ms(150); } if(input(pin_D1)==0) //cho D1 xuong muc 0 mk = 0x11; { output_b('#'); //ghi # display(); delay_ms(150); } //*************************************** output_d(0b10111111); //Hang 1 chan RD6 xuong muc 0 delay_ms(10); if(input(pin_D3)==0) //cho D3 xuong muc 0 mk = 0x01; { output_b(0x31); //ghi 1 display(); delay_ms(150); } if(input(pin_D2)==0) //cho D2 xuong muc 0 mk = 0x02; { output_b(0x32); //ghi 2 display(); delay_ms(150); } if(input(pin_D1)==0) //cho D1 xuong muc 0 mk = 0x03; { output_b(0x33); //ghi 3 display(); delay_ms(150); } //*************************************** output_d(0b11011111); //Hang 2 chan RD5 xuong muc 0 delay_ms(10); if(input(pin_D3)==0) //cho D3 xuong muc 0 mk = 0x04; { output_b(0x34); //ghi 4 display(); delay_ms(150); } if(input(pin_D2)==0) //cho D2 xuong muc 0 mk = 0x05; { output_b(0x35); //ghi 5 display(); delay_ms(150); } if(input(pin_D1)==0) //cho D1 xuong muc 0 mk = 0x06; { output_b(0x36); //ghi 6 display(); delay_ms(150); } //***************************************** output_d(0b11101111); //Hang 3 chan RD4 xuong muc 0 delay_ms(10); if(input(pin_D3)==0) //cho D3 xuong muc 0 mk = 0x07; { output_b(0x37); //ghi 7 display(); delay_ms(150); } if(input(pin_D2)==0) //cho D2 xuong muc 0 mk = 0x08; { output_b(0x38); //ghi 8 display(); delay_ms(150); } if(input(pin_D1)==0) //cho D1 xuong muc 0 mk = 0x09; { output_b(0x39); //ghi 9 display(); delay_ms(150); } return mk; } } } Lúc mình compile sang file hex thì nó báo lỗi như sau: |
|
|