本帖最后由 widpj 于 2011-5-13 21:24 编辑
大侠们帮忙看下我这电路图错在哪?为什么不能仿真?程序我也贴出来了!!
急啊…………
大虾们能不能直接点中要害,指出一个模糊概念本人实在不知道怎么办!!!
#include <reg52.h>
#include <string.h> // 包含头文件
#define uchar unsigned char
#define unint unsigned int
char data1[]="time is always go!" ;
char data2[]="never stop!! " ;
//**********************延时函数*******************************************//
void DelayS(unsigned int a)
{ unint i,j ;
for(i=0;i<a;i++)
{ for(j=0;j<255;j++)
{;;}
}
}
void DelayS250(void){
DelayS(250);
}
//=================================lcd模块驱动===========================================//
/********************************************************************************************/
#define lcd_DB0_DB7 P0 // 定义lcd的数据总线
sbit lcd_RS = P1^0; // 定义lcd的RS控制线
sbit lcd_RW = P1^2; // 定义lcd的RW控制线
sbit lcd_E = P1^1; // 定义lcd的E控制线
//sbit lcd_Busy = P1 ^ 3; // 定义lcd的测忙线(与lcd_DB0_DB7关联)
//******************************************检测lcd状态***********************************//
//void lcd_TestBusy(void){
// lcd_DB0_DB7 = 0xff;//设备读状态
// lcd_RS = 0;
// lcd_RW = 1;
// lcd_E = 1;
// while(lcd_Busy);//等待LCD不忙 (P0口得第七位) 如果lcd_Busy为真(及1)重复,否则退出循环。
// lcd_E = 0;//
// }
//**************************写数据************************************************//
void lcd_writedata(uchar lcd_data)
{
// lcd_TestBusy();
lcd_DB0_DB7 = lcd_data;
lcd_RS = 1;
lcd_RW = 0;
lcd_E = 1;
lcd_E = 0;
}
//***********************lcd 写指令**********************************************//
void lcdwrite_command( uchar lcdwrite_command )
{
// lcd_TestBusy();
lcd_DB0_DB7 = lcdwrite_command;
lcd_RS = 0;
lcd_RW = 0;
lcd_E = 1;
lcd_E = 0;
}
//************************lcd 初始化******************************************//
void init_lcd(void)
{
DelayS(15);
lcdwrite_command(0x38);
DelayS(5);
lcdwrite_command(0x38);
DelayS(5);
lcdwrite_command(0x38);
lcdwrite_command(0x38);// 显示显示模式设置
lcdwrite_command(0x08); // 显示关闭
lcdwrite_command(0x01); //显示清屏
lcdwrite_command(0x06);//显示光标移动设置
lcdwrite_command(0x0c) ; //显示开及光标设置
}
//*************************** 显示****************************//
// void print(uchar a,uchar b)
// { lcdwrite_command(a);
// lcdwrite_data(b);
//
// }
//***************************************************************//
void print(uchar a,uchar *str){
lcdwrite_command(a);
while(*str != '\0'){
lcd_writedata(*str++);
}
*str = 0;}
//*******************************主函数********************************//
void main(void)
{
init_lcd();
while(1)
{
print(0x80,"time is always go!");
print(0xc0,"never stop!! ");
DelayS(255);
lcdwrite_command(0x07);
DelayS(255);
DelayS(255); DelayS(255);
DelayS(255);
print(0x80,"time is always go!");
print(0xc0,"never stop!! ");
}
} |