|
为什么我在IDE下编的程序编译时老显示找不到HEX文件 程序如下
#include <reg51.h>
#include <intrins.h>
sbit dc=0xa2; /*P2.2 LCD 的RS 21*/
sbit rw=0xa1; /*P2.1 LCD 的R/W 22*/
sbit cs=0xa0; /*P2.0 LCD 的E 25*/
sfr lcdbus=0x80; /*p0 LCD 数据 D0=P0.0*/
unsigned int sys10mscounter;
unsigned char syslimitcounter;
char path1[8]={0x00,0x1f,0x00,0x1f,0x00,0x1f,0x00,0x1f};/*自定义符号:横1*/
char path2[8]={0x1f,0x00,0x1f,0x00,0x1f,0x00,0x1f,0x00};/*自定义符号:横2*/
char pats1[8]={0x15,0x15,0x15,0x15,0x15,0x15,0x15,0x15};/*自定义符号:竖1*/
char pats2[8]={0x0a,0x0a,0x0a,0x0a,0x0a,0x0a,0x0a,0x0a};/*自定义符号:竖2*/
void soft_nop()
{}
void soft_10ms()/***********12MHZ提供 10MS 软件延时************/
{
register int i;
for(i=0;i<711;i++);
}
void soft_20ms()/***********12MHZ提供 20MS 软件延时************/
{
soft_10ms();
soft_10ms();
}
void hard_10ms(unsigned int delaytime) /*基于 10MS 的硬件延时*/
{
sys10mscounter=delaytime;
while(sys10mscounter);
}
unsigned char data lcdcounter;
bit lcdusing1,lcdusing2;
bit lcd_checkbusy()/*检查 LCD 忙*/
{
register lcdstate;
dc=0; /*dc=1为数据,=0为命令.*/
rw=1; /*rw=1为读,=0为写.*/
cs=1; /*cs=1选通.*/
soft_nop();
lcdstate=lcdbus;
cs=0;
return((bit)(lcdstate&0x80));
}
void lcd_wrcmd(unsigned char lcdcmd) /*写LCD 命令*/
{
lcdusing1=1;
while(lcd_checkbusy());
lcdbus=lcdcmd;
dc=0; /*dc=1为数据,=0为命令.*/
rw=0; /*rw=1为读,=0为写.*/
cs=1; /*cs=1选通.*/
soft_nop();
cs=0;
lcdbus=0xff;
lcdusing1=0;
}
void lcd_moveto(char position) /*移动光标到指定位.0-79*/
{
register cmd=0x80;
lcdcounter=position;
if (position > 59)
position += 0x18;
else
{ if (position > 39)position -= 0x14;
else
{ if (position > 19)position += 0x2c;
}
}
cmd=cmd|position;
lcd_wrcmd(cmd);
}
void lcd_wrdata(char lcddata) /*在当前显示位置显示数据*/
{
lcdusing2=1;
while(lcd_checkbusy());
if(lcdcounter==20)
{
lcd_moveto(20);
while(lcd_checkbusy());
}
if(lcdcounter==40)
{
lcd_moveto(40);
while(lcd_checkbusy());
}
if(lcdcounter==60)
{
lcd_moveto(60);
while(lcd_checkbusy());
}
if(lcdcounter==80)
{
lcd_moveto(0);
while(lcd_checkbusy());
lcdcounter=0;
} /*为通用而如此*/
lcdcounter++;
lcdbus=lcddata;
dc=1; /*dc=1为数据,=0为命令.*/
rw=0; /*rw=1为读,=0为写.*/
cs=1; /*cs=1选通.*/
soft_nop();
cs=0;
lcdbus=0xff;
lcdusing2=0;
}
void lcd_string(char *strpoint) /*在当前显示位置显示 LCD 字符串*/
{
register i=0;
while(strpoint!=0)
{
lcd_wrdata(strpoint);
i++;
}
}
void lcd_init()/*初始化*/
{
lcd_wrcmd(0x38); /*设置8 位格式,2 行,5*7*/
lcd_wrcmd(0x0c); /*整体显示,关光标,不闪烁*/
lcd_wrcmd(0x06); /*设定输入方式,增量不移位*/
lcd_wrcmd(0x01); /*清除显示*/
lcdcounter=0;
}
void lcd_cls()/*清除显示*/
{
lcd_wrcmd(0x01);
lcdcounter=0;
}
void timer0(void) interrupt 1 /*T0 中断*/
{
TH0=0xd8; /*12M,10ms*/
TL0=0xf6;
TR0=1;
if(sys10mscounter!=0)sys10mscounter--; /*定时器10ms*/
if(syslimitcounter!=0)syslimitcounter--; /*定时器10ms*/
}
main()
{
unsigned char j;
IE=0;
P0=0xff;
P1=0xff;
P2=0xff;
P3=0xff; /*初始化 T*/
lcd_init();
soft_20ms();
TMOD=0x51;
TH0=0xd8; /*12M,10ms*/
TL0=0xf6;
TR0=1;ET0=1;EA=1;
while(1)
{
/*全黑、横一、横二、竖一、竖二、U、Q、ABCD...,*/
lcd_init(); /*全黑*/
for(j=0;j<80;j++){lcd_wrdata(0xff);}
hard_10ms(50);
lcd_init(); /*横一,可参考自行设计符号*/
lcd_wrcmd(0x40);
for(j=0;j<8;j++)lcd_wrdata(path1[j]);
for(j=0;j<100;j++)lcd_wrdata(0);
hard_10ms(50);
lcd_init(); /*横二*/
lcd_wrcmd(0x40);
for(j=0;j<8;j++)lcd_wrdata(path2[j]);
for(j=0;j<100;j++)lcd_wrdata(0);
hard_10ms(50);
lcd_init(); /*竖一*/
lcd_wrcmd(0x40);
for(j=0;j<8;j++)lcd_wrdata(pats1[j]);
for(j=0;j<100;j++)lcd_wrdata(0);
hard_10ms(50);
lcd_init(); /*竖二*/
lcd_wrcmd(0x40);
for(j=0;j<8;j++)lcd_wrdata(pats2[j]);
for(j=0;j<100;j++)lcd_wrdata(0);
hard_10ms(50);
lcd_init();
lcd_string("UUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUU"
);
hard_10ms(50);
lcd_init();
lcd_string("QQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQ"
);
hard_10ms(50);
lcd_init();
lcd_string("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz0123456789+-!#$%&?"
);
hard_10ms(50);
}
} |
阿莫论坛20周年了!感谢大家的支持与爱护!!
曾经有一段真挚的爱情摆在我的面前,我没有珍惜,现在想起来,还好我没有珍惜……
|