ATmega16液晶12864.docx

上传人:b****5 文档编号:2779356 上传时间:2022-11-15 格式:DOCX 页数:32 大小:19.98KB
下载 相关 举报
ATmega16液晶12864.docx_第1页
第1页 / 共32页
ATmega16液晶12864.docx_第2页
第2页 / 共32页
ATmega16液晶12864.docx_第3页
第3页 / 共32页
ATmega16液晶12864.docx_第4页
第4页 / 共32页
ATmega16液晶12864.docx_第5页
第5页 / 共32页
点击查看更多>>
下载资源
资源描述

ATmega16液晶12864.docx

《ATmega16液晶12864.docx》由会员分享,可在线阅读,更多相关《ATmega16液晶12864.docx(32页珍藏版)》请在冰豆网上搜索。

ATmega16液晶12864.docx

ATmega16液晶12864

/*

*lcd_12864.c

*

*Created:

2015/2/1616:

01:

32

*Author:

Administrator

*/

/************************************************************************/

/*常用头文件及宏定义*/

/************************************************************************/

#include

#include//延时文件

#include//睡眠文件

#include//中断文件

#include//eeprom

#defineBIT(x)(1<<(x))

#defineucharunsignedchar

#defineuintunsignedint

/************************************************************************/

/*12864*/

/************************************************************************/

/*并行模式*/

/*引脚说明*/

/*PC0RSPC1RWPC2EPC3背光PC4RST*/

/*PA0~PA7数据*/

//宏定义

/*

#defineDDR_SHUJUDDRA

#definePORT_SHUJUPORTA

#definePIN_SHUJUPINA

#defineDDR_KZDDRC

#definePORT_KZPORTC

#defineRS_HPORT_KZ|=BIT(0)

#defineRS_LPORT_KZ&=~(BIT(0))

#defineRW_HPORT_KZ|=BIT

(1)

#defineRW_LPORT_KZ&=~(BIT

(1))

#defineE_HPORT_KZ|=BIT

(2)

#defineE_LPORT_KZ&=~(BIT

(2))

#defineBEIGUABG_HPORT_KZ|=BIT(3)

#defineBEIGUABG_LPORT_KZ&=~(BIT(3))

#defineRESETPORT_KZ&=~(BIT(4)),PORT_KZ|=BIT(4)

ucharlcd_read()//读忙函数

{

ucharbl;

DDR_SHUJU=0;//输入

PORT_SHUJU=0xff;//上拉电阻

RS_L;

RW_H;

E_H;

_delay_ms

(1);

bl=PIN_SHUJU;

E_L;

RW_L;

PORT_SHUJU=0;

DDR_SHUJU=0xff;

returnbl;

}

voidlcd_write_char(ucharshuju)//写字符函数

{

while(lcd_read()&BIT(7));

RS_H;

RW_L;

PORT_SHUJU=shuju;

E_H;

E_L;

RS_L;

}

voidlcd_write_string(char*str)//写字符串函数

{

while(*str!

='\0')

{

lcd_write_char(*str);

str++;

}

}

voidlcd_write_zhiling(ucharzhiling)//写指令

{

while(lcd_read()&BIT(7));

RS_L;

RW_L;

PORT_SHUJU=zhiling;

E_H;

E_L;

}

//指令集宏定义//

#defineZHILINGJI_JIBENlcd_write_zhiling(0x30)//基本指令集

#defineZHILINGJI_KUOZHANlcd_write_zhiling(0x34)//扩展指令集

#defineHUITU_OFFlcd_write_zhiling(0x34)//绘图关

#defineHUITU_ONlcd_write_zhiling(0x36)//绘图开

#defineQINGPING_WENZIlcd_write_zhiling(0x01)//文字清屏

voidhuitu_qingping()

{

uchari,j;

ZHILINGJI_KUOZHAN;//扩充指令集

HUITU_OFF;//绘图关

for(i=0;i<32;i++)

{

lcd_write_zhiling(0x80+i);//y地址

lcd_write_zhiling(0x80);//x地址

ZHILINGJI_JIBEN;//基本指令集

for(j=0;j<16;j++)

{

lcd_write_char(0);//数据

lcd_write_char(0);//数据

}

ZHILINGJI_KUOZHAN;//扩充指令集

}

HUITU_ON;//开显示

}

voidhuitu_fenkuai(ucharX,ucharY,uchartu[])

{

uchari;

switch(Y)

{

case1:

X+=0;break;

case2:

X+=8;break;;

default:

;

}

X--;

ZHILINGJI_KUOZHAN;//扩充指令集

HUITU_OFF;//绘图关

for(i=0;i<32;i++)

{

lcd_write_zhiling(0x80+i);//y地址

lcd_write_zhiling(0x80+X);//x地址

ZHILINGJI_JIBEN;//基本指令集

lcd_write_char(tu[2*i]);//数据

lcd_write_char(tu[2*i+1]);//数据

ZHILINGJI_KUOZHAN;//扩充指令集

}

HUITU_ON;//绘图开

}

voidhuitu_quanping(uchartu[],ucharn)

{

inti,j,k=0;

ZHILINGJI_KUOZHAN;//扩充指令集

HUITU_OFF;//绘图关

if(n==1)

{

for(i=0;i<32;i++)

{

lcd_write_zhiling(0x80+i);//y地址

lcd_write_zhiling(0x80);//x地址

ZHILINGJI_JIBEN;//基本指令集

for(j=0;j<8;j++,k++)

{

lcd_write_char(tu[k]);//数据

k++;

lcd_write_char(tu[k]);//数据

}

ZHILINGJI_KUOZHAN;//扩充指令集

}

}

else

{

for(i=0;i<32;i++)

{

lcd_write_zhiling(0x80+i);//y地址

lcd_write_zhiling(0x88);//x地址

ZHILINGJI_JIBEN;//基本指令集

for(j=0;j<8;j++,k++)

{

lcd_write_char(tu[k]);//数据

k++;

lcd_write_char(tu[k]);//数据

}

ZHILINGJI_KUOZHAN;//扩充指令集

}

HUITU_ON;//开显示

}

}

voidchushihua_12864()

{

PORT_SHUJU=0;

DDR_SHUJU=0xff;

PORT_KZ|=BIT(4);

DDR_KZ=0xff;

RESET;

ZHILINGJI_JIBEN;//基本指令集

lcd_write_zhiling(0x08);//显示关

lcd_write_zhiling(0x01);//清显示

lcd_write_zhiling(0x02);//地址归位

lcd_write_zhiling(0x10);//设置游标

lcd_write_zhiling(0x0c);//开显示

huitu_qingping();

}

voidtuxiang_1()

{

uchartu[513]={

0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

0x00,0x00,0x00,0x00,0x00,0x00,0x12,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x20,0x0E,0x0E,0x00,0x00,0x00,0x00,0x00,0x00,

0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x08,0x11,0x11,0x10,0x00,0x00,0x00,0x00,0x00,

0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x40,0xB0,0xA1,0x88,0x00,0x00,0x00,0x00,0x00,

0x00,0x00,0x00,0x00,0x00,0x01,0x62,0x19,0x10,0x41,0x00,0x00,0x00,0x00,0x00,0x00,

0x00,0x00,0x00,0x00,0x00,0x04,0x07,0x08,0x08,0x02,0x01,0x00,0x00,0x00,0x00,0x00,

0x00,0x00,0x00,0x00,0x00,0x15,0x40,0x40,0x04,0x04,0x00,0x80,0x00,0x00,0x00,0x00,

0x00,0x00,0x00,0x00,0x00,0x00,0x41,0x11,0x02,0x08,0x00,0x00,0x00,0x00,0x00,0x00,

0x00,0x00,0x00,0x00,0x00,0x00,0xD0,0

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 工程科技 > 能源化工

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1