一,打开文件(可以随文下载放置在文档中打开)。(如下图1所示)
图1
二,调整原理图大小,适合可视,另存工程文件。(如下图2,3,4所示)
图2
四,编辑main.c 代码如Proteus8.9 VSM Studio Keil编译器仿真AT89C51RD2系列016_lcd12064bit (如下图6所示)
图6
五,Main.c 代码:
/* Main.c file generated by New Project wizard
*Coder: Ziegler Yin
#include “lcd16024bit.h”
int lcd_putstr(u8 *ddat, int pos)
{
u8 i;
if(pos== -1) {
write_com(0x01);
delay(2); pos= 0;
}
while((*ddat)!= ‘\0’) {
switch(*ddat) {
case ‘\n’:
if(pos< 17) {
for(i= pos; i< 16; i++) lcd_wrtchr(pos% 16, pos/ 16, ’ ');
pos=16;
}
else {
for(i= pos; i< 32; i++) lcd_wrtchr(pos% 16, pos/ 16, ’ ');
pos=0;
}
break;
case ‘\b’:
if(pos>0) pos–;
lcd_wrtchr(pos% 16, pos/ 16, ’ ');
break;
default:
if((*ddat) < 0x20) {
*ddat= ’ ';
}
lcd_wrtchr(pos% 16, pos/ 16, *ddat);
pos++;
break;
}
*ddat++;
}
return (pos);
}
int lcd_putnum(u32 num, int XS, int pos)
{
u32 tmp= 0;
u8 numbits= 0;
if(pos== -1) {
write_com(01);
delay(2); pos= 0;
}
if(num== 0) {
lcd_wrtchr(pos% 16, pos/16, ‘0’);
pos++;
}
else {
if(num< 0) {
lcd_wrtchr(pos% 16, pos/16, ‘-’);
num*= (-1);
pos++;
}
while(num) {
tmp= tmp* 10+ (num% 10);
num= num/ 10;
numbits++;
}
while(tmp) {
lcd_wrtchr(pos% 16, pos/16, (tmp% 10) +48);
tmp /=10;
pos++;
numbits–;
if(numbits== XS) pos= lcd_putstr(".", pos);
}
while(numbits–) {
lcd_wrtchr(pos% 16, pos/16, ‘0’);
pos–;
}
}
return (pos);
}
void main(void)
{
init();
while(1){
LClear();
delay(500);
lcdStr(0, 0, “Kaillen Work”);
lcdStr(0, 1, " Wellcom YOU!");
delay(5000);
LClear();
delay(500);
lcdStr(0, 0, “Code Made”);
lcdStr(0, 1, " --Ziegler Yin");
delay(5000);
}
}
Lcd16024bit.h:
/* Main.c file generated by New Project wizard
*Coder: Ziegler Yin
#ifndef _LCD16024BIT_H
#define _LCD16024BIT_H
#include
#include
#include “INTRINS.H”
#define u32 unsigned long
#define u16 unsigned int
#define u8 unsigned char
sbit lcdrs =P2^7; //液晶屏数据/命令选择端
sbit lcdrw =P2^6; //液晶屏读写端
sbit lcden =P2^5; //使能端
void delay(int z);
void write_com(u8 com);
void write_data(u8 date );
void SetCursor(u8 ix, u8 iy);
void lcd_wrtchr(u8 X, u8 Y, u8 recd);
void lcdStr(u8 x, u8 y, u8 *str);
void init(void);
void LClear(void);
#endif
七,点击窗口左下方仿真按钮,可见lcd16024bit屏上信息显示在屏。 (如下图8,9,10所示)
图8
八,选择release,点击构建工程按钮,编译工程生成Hex文件。(如下图11所示)
图11
九, 系列的001-003虚拟仿真与开发板对应已证明:虚拟仿真程序对于开发板有效,之后不再➕上下载到开发板的介绍。
附件下载:https://download.csdn.net/download/kaillen/12439463
Proteus8.9 SP2下载:https://download.csdn.net/download/kaillen/12459968
附件Proteus8.9 VSM Studio Keil编译器仿真AT89C51RD2系列016_lcd12064bit在已安装Proteus8.9的计算机文件夹中打开即可
需要进一步了解,请加入QQ群:976235464