谁有成功的st7920程序

来源:百度知道 编辑:UC知道 时间:2024/09/20 11:43:49
sbit rs = P2^2;
sbit rw = P2^3;
sbit e = P2^4;
sbit psb= P2^5;

P0口为DB0--DB7

麻烦高手帮助

#include <reg51.h>
#include <intrins.h>
#include <stdio.h>
#define uchar unsigned char
#define Fisrt_Addr 0 //定义字符/汉字显示起始位置

typedef unsigned char uint8;

sbit LCD_RS=P2^2;
sbit LCD_RW=P2^3;
sbit LCD_E=P2^4;
sbit PCB=P2^5;
uchar i,j;
uint8 AC_TABLE[]={
0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87, //第一行汉字位置
0x90,0x91,0x92,0x93,0x94,0x95,0x96,0x97, //第二行汉字位置
0x88,0x89,0x8a,0x8b,0x8c,0x8d,0x8e,0x8f, //第三行汉字位置
0x98,0x99,0x9a,0x9b,0x9c,0x9d,0x9e,0x9f, //第四行汉字位置
};

void delay(int ms)
{
while(ms--)
{
for(j=0;j<120;j++);
}
}

bit lcd_busy()
{ bit result;
LCD_RS=0;
LCD_RW=1;
LCD_E= 1;
result=(bit)(P0&0x80);
LCD_E=0;
return result;
}
void lcd_wcmd(uchar cmd)
{
while(lcd_busy());
LCD_RS=0;