📄 12864-1.c
字号:
#include <iom16v.h>
#include <macros.h>
//-----------------------------------------------
#define uchar unsigned char
#define uint unsigned int
//---------------引脚电平的宏定义
#define RS_H PORTC|=BIT(PC7)
#define RS_L PORTC&=~BIT(PC7)
#define RW_H PORTC|=BIT(PC6)
#define RW_L PORTC&=~BIT(PC6)
#define E_H PORTC|=BIT(PC5)
#define E_L PORTC&=~BIT(PC5)
#define uchar unsigned char
#define uint unsigned int
//#pragma data:code
const uchar table[]="支持奥运中国加油";
const uchar table1[]="广东工业";
const uchar table2[]="信息工程";
const uchar table3[]="xuquanrui";
void delay(uint k)
{
uint i,j;
for(i=0;i<k;i++)
for(j=0;j<1140;j++);
}
void Init()
{
DDRA=0XFF;
DDRC|=BIT(5)|BIT(6)|BIT(7);
write_com(0x30);//功能设定(见资料第六点)
write_com(0x0c);//显示开关设置(见资料第四点)
write_com(0x01);//清屏(见资料第一点)
write_com(0x06);//进入设定点,游标(见资料第三点)
write_com(0x02);//地址归0(见资料第二点)
// write_com(0x07);
}
void write_com(uchar com)
{
RS_L;
RW_L;
PORTA=com;
E_H;
delay(1);
E_L;
}
void write_dat(uchar dat)
{
RS_H;
RW_L;
PORTA=dat;
E_H;
delay(1);
E_L;
}
read_data()
{
uchar data;
delay(5);
RS_H;RW_H;
DDRA=0;
E_H;NOP();
data=PINA;
delay(1);
E_L;
DDRA=0XFF;
return (data);
}
void main()
{
uchar i;
Init();
delay(5);
write_com(0x80);
for(i=0;i<16;i++)
{
write_dat(table[i]);
delay(5);
}
write_com(0x34);
write_com(0X04);
write_com(0X05);
write_com(0x30);
write_com(0x90+2);
for(i=0;i<8;i++)
{
write_dat(table1[i]);
delay(5);
}
write_com(0x34);
write_com(0X04);
write_com(0X05);
write_com(0x30);
while(1);
/* write_com(0x90+2);
for(i=0;i<8;i++)
{
write_dat(table1[i]);
delay(5);
}
write_com(0x88+2);
for(i=0;i<8;i++)
{
write_dat(table2[i]);
delay(5);
}
write_com(0x98+2);
for(i=0;i<10;i++)
{
write_dat(table3[i]);
delay(5);
}
//write_com(0x34);
//write_com(0x06);
//write_com(0x80);
//write_com(0x30);
*/
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -