📄 s6a0094.c
字号:
#include <AT89X52.H>
#include <intrins.h>
#define RS P3_3
#define RW P3_1
#define E P3_0
#define DATA_BUS P1
void Delay(unsigned int n)
{
while(n--);
return;
}
#pragma disable
void Write_Data(unsigned char dat)
{
RS=1;
RW=0;
E=1;
_nop_();
DATA_BUS=dat;
E=0;
Delay(10);
return;
}
#pragma disable
void Write_Instruction(unsigned char cmd)
{
RS=0;
RW=0;
_nop_();
E=1;
_nop_();
DATA_BUS=cmd;
_nop_();
E=0;
Delay(10);
return;
}
void initial()
{
/*
Write_Instruction(0x31);
Write_Instruction(0x88);
Write_Data(0x1f);
Write_Instruction(0x42);
Write_Instruction(0x51);
Delay(200);//waiting>1ms
Write_Instruction(0x55);
Delay(200);//waiting>1ms
Write_Instruction(0x57);
Delay(100);//waiting>500us
Write_Instruction(0x33);
Write_Instruction(0x5b);
*/
unsigned char i;
Write_Instruction(0x30);//RE=0
Write_Instruction(0x60);//R1~R0=00,CS=0,CG=0(CGROM)
Write_Instruction(0x20);//line blink mode
Write_Instruction(0x32);//RE=1
Write_Instruction(0x10);//determination of the DDRAM line which is display
//Write_Instruction(0x20);//douuble height mode
Write_Instruction(0x60);//SS=0
Write_Instruction(0x5d);//IRS=1(internal resistors are used for regulator),BS=0(BIAS=1/4),IR1~IR0=10(1+Rb/Ra)
Write_Instruction(0x30);//RE=0
Write_Instruction(0x88);//electronic volume register setup 0x08h
Write_Data(0x10);//0x00~0x1f EV contrast
Write_Instruction(0x42);//OS=1(Oscillator) on,PS=0(power save off)
//POWER ON
Write_Instruction(0x51);
Delay(200);//waiting>1ms
Write_Instruction(0x55);
Delay(200);//waiting>1ms
Write_Instruction(0x57);
Delay(100);//waiting>500us
Write_Instruction(0x30);
Write_Instruction(0xb0);//DDRAM address
for(i=0;i<80;i++)//clear DDRAM
{
Write_Data(0x20);
}
Write_Instruction(0x30);//RE=0
Write_Data(0x10);//AC TO 30H,cursor returens to home position
Write_Instruction(0x31);//RE=1,Dislay on
return;
}
void display()
{
Write_Instruction(0x31);//re=0,display on
Write_Instruction(0xC0);//DDRAM line2
Write_Data(0x42);//display"A"
}
void main()
{
Delay(1000);
initial();
while(1)
{
display();
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -