mấy anh xem dùm e chương trình này sao lại không hiển thị được trên mô phỏng Proteus
nạp trên bo mạch thực tế thì lại chạy??
file mô phỏng: http://www.mediafire.com/?buefa5a9vkahghh
code:
#include <AT89X51.H>
#include <stdio.h>
unsigned int n,i,a;
//UNSIGNED INT8 i;
void delay_ms (n)
{
for (i=0;i<=n;i++)
{for (a=0;a<=100;a++);}
}
void OE(void)
{
P2_3=1; //E
P2_3=0;
}
void main (void)
{
P2 = 0x00; // Tat het cac chan
P1 = 0x00;
P2_3=0;
delay_ms(1000);
// Khoi tao LCD
P2_2=0; //RS
P1=0x38; // Port 1 noi voi DATA
OE(); //Che do data 8 bit; 2 line; 5x7dots
delay_ms(100);
P1=0x0C;
OE(); // DISPLAY ON/OFF 0000DCB--- Cai dat con tro va hien thi D=1;C=0;B=0
delay_ms(100);
P1=0x01;
OE(); //Clear display
delay_ms(100);
P1=0x02;
OE(); //Cursor home
delay_ms(100);
///////// Doan hien thi chu
P2_2=1; // Xuat data
P1=0x57; // Xuat chu W
OE();
delay_ms(100);
P1=0x45; // Xuat chu E
OE();
delay_ms(100);
P1=0x4C; // Xuat chu L
OE();
delay_ms(100);
P1=0x43; // Xuat chu C
OE();
delay_ms(100);
P1=0x4F; // Xuat chu O
OE();
delay_ms(100);
P1=0x4D; // Xuat chu M
OE();
delay_ms(100);
P1=0x45; // Xuat chu E
OE();
delay_ms(100);
P1=0xA0; // Xuat chu RONG ??????????????
OE();
delay_ms(100);
P1=0x54; // Xuat chu T
OE();
delay_ms(100);
P1=0x4F; // Xuat chu 0
OE();
delay_ms(100);
P1=0xA0; // Xuat chu RONG
OE();
delay_ms(100);
P1=0x56; // Xuat chu V
OE();
delay_ms(100);
P1=0x49; // Xuat chu I
OE();
delay_ms(100);
P1=0x54; // Xuat chu T
OE();
delay_ms(100);
P1=0x43; // Xuat chu C
OE();
delay_ms(100);
P1=0x4F; // Xuat chu 0
OE();
delay_ms(100);
P2_2=0; //Xuat lenh
P1=0xC5; // Xuong hang - vi tri 5
OE();
delay_ms(100);
P2_2=1; //Xuat data
P1=0x48; // Xuat chu H
OE();
delay_ms(100);
P1=0x49; // Xuat chu I
OE();
delay_ms(100);
P1=0xA0; // Xuat chu RONG
OE();
delay_ms(100);
P1=0x21; // Xuat chu !
OE();
delay_ms(100);
P1=0x21; // Xuat chu !
OE();
delay_ms(100);
P1=0x21; // Xuat chu !
OE();
delay_ms(100);
delay_ms(2000);
for ( ; ; )
{
P2_2=0; //Xuat lenh
P1=0x18; // XOAY CHU
OE();
delay_ms(500);
}
}
nạp trên bo mạch thực tế thì lại chạy??
file mô phỏng: http://www.mediafire.com/?buefa5a9vkahghh
code:
#include <AT89X51.H>
#include <stdio.h>
unsigned int n,i,a;
//UNSIGNED INT8 i;
void delay_ms (n)
{
for (i=0;i<=n;i++)
{for (a=0;a<=100;a++);}
}
void OE(void)
{
P2_3=1; //E
P2_3=0;
}
void main (void)
{
P2 = 0x00; // Tat het cac chan
P1 = 0x00;
P2_3=0;
delay_ms(1000);
// Khoi tao LCD
P2_2=0; //RS
P1=0x38; // Port 1 noi voi DATA
OE(); //Che do data 8 bit; 2 line; 5x7dots
delay_ms(100);
P1=0x0C;
OE(); // DISPLAY ON/OFF 0000DCB--- Cai dat con tro va hien thi D=1;C=0;B=0
delay_ms(100);
P1=0x01;
OE(); //Clear display
delay_ms(100);
P1=0x02;
OE(); //Cursor home
delay_ms(100);
///////// Doan hien thi chu
P2_2=1; // Xuat data
P1=0x57; // Xuat chu W
OE();
delay_ms(100);
P1=0x45; // Xuat chu E
OE();
delay_ms(100);
P1=0x4C; // Xuat chu L
OE();
delay_ms(100);
P1=0x43; // Xuat chu C
OE();
delay_ms(100);
P1=0x4F; // Xuat chu O
OE();
delay_ms(100);
P1=0x4D; // Xuat chu M
OE();
delay_ms(100);
P1=0x45; // Xuat chu E
OE();
delay_ms(100);
P1=0xA0; // Xuat chu RONG ??????????????
OE();
delay_ms(100);
P1=0x54; // Xuat chu T
OE();
delay_ms(100);
P1=0x4F; // Xuat chu 0
OE();
delay_ms(100);
P1=0xA0; // Xuat chu RONG
OE();
delay_ms(100);
P1=0x56; // Xuat chu V
OE();
delay_ms(100);
P1=0x49; // Xuat chu I
OE();
delay_ms(100);
P1=0x54; // Xuat chu T
OE();
delay_ms(100);
P1=0x43; // Xuat chu C
OE();
delay_ms(100);
P1=0x4F; // Xuat chu 0
OE();
delay_ms(100);
P2_2=0; //Xuat lenh
P1=0xC5; // Xuong hang - vi tri 5
OE();
delay_ms(100);
P2_2=1; //Xuat data
P1=0x48; // Xuat chu H
OE();
delay_ms(100);
P1=0x49; // Xuat chu I
OE();
delay_ms(100);
P1=0xA0; // Xuat chu RONG
OE();
delay_ms(100);
P1=0x21; // Xuat chu !
OE();
delay_ms(100);
P1=0x21; // Xuat chu !
OE();
delay_ms(100);
P1=0x21; // Xuat chu !
OE();
delay_ms(100);
delay_ms(2000);
for ( ; ; )
{
P2_2=0; //Xuat lenh
P1=0x18; // XOAY CHU
OE();
delay_ms(500);
}
}
Comment