12864(带字库)串行方式显示汉字和字库-CVAVR程序

发布者:WiseThinker最新更新时间:2016-10-30 来源: eefocus关键字:带字库  串行方式显示  AVR程序 手机看文章 扫描二维码
随时随地手机看文章
// HS12864-15B —— 串行  

// 带字库
// 芯片 ATMEGA16L 
// 时钟 4MHz 内部
// 采用系统自带延时程序  
// 检测忙闲 
// 功能1:显示汉字和字母
// 功能2:图形显示,显示横线、竖线、边框、128*64图像、64*64图像,图形显示较慢
// 注意:采用了文本区和图形区清零函数,汉字和图形显示切换时要注意,基本指令集和扩充指令集的转换    
// 保存图像的数组最后不能有逗号

#include  
#include

#define  cs        PORTD.2  // 片选信号
#define  sid       PORTD.3  // 串行数据线输出  
#define  sid_in    3        // 串行数据线输入
#define  sclk      PORTD.4  // 时钟输入线
#define  psb       PORTD.5  // psb=H,并口模式, psb=L,串口模式
#define  rst       PORTD.6  // LCD复位,低有效
#define  run       PORTB.7  // 运行标志

void LCD_send_byte(unsigned char a);      // LCD写数据  
unsigned char LCD_read_byte(void);        // LCD读数据  
void chk_busy(void);                      // 检测忙闲
void init_lcd(void);                      // 初始化
void wr_data(unsigned char dat);          // 写数据到LCD
void wr_comm(unsigned char comm);         // 写命令到LCD
void img_disp(unsigned char flash *img);  // 显示图片128*64
void img_disp2(unsigned char flash *img); // 显示图片64*64  左半屏
void img_disp3(unsigned char flash *img); // 显示图片64*64  右半屏
void lcdfill(unsigned char disdata);      // 整屏全亮或显示竖条
void Disp_H_Line(void);                   // 显示横条
void frame(void);                         // 显示边框 
void wr_str(unsigned char flash *s);      // 写字符串
void hz_disp(void);                       // 写汉字或字母
void LcdClearTXT(void);                   // 文本区RAM清零
void LcdClearBMP(void);                   // 图形区RAM清零
                                                            
flash unsigned char ex1[] = {"泰  山  电 子"};  //字符串以\0结束
flash unsigned char ex2[] = {"  欢  迎  您  "};
flash unsigned char ex3[] = {"TAI SHAN DIAN ZI"};  
flash unsigned char ex4[] = {"Wellcome to you!"};   
flash unsigned char ex5[] = {"黄河远上白云间"}; 
flash unsigned char ex6[] = {"一片孤城万仞山"};
flash unsigned char ex7[] = {"羌笛何须怨杨柳"};  
flash unsigned char ex8[] = {"春风不度玉门关"};
flash unsigned char ex9[] = {"TAI SHAN DIAN ZI"}; 
flash unsigned char ex10[] = {"Designer:Charlie"};  

flash unsigned char tab[]={ 
/*--  调入了一幅图像:联通图标 4567.bmp  --*/
/*--  宽度x高度=128x64  --*/
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,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,0X00,0X00,0X00,0X00,
0X00,0X00,0X00,0X00,0X00,0X07,0XFF,0X00,0X00,0X1F,0XFC,0X00,0X00,0X00,0X00,0X00,
0X00,0X00,0X00,0X00,0X00,0X3F,0XFF,0XE0,0X00,0XFF,0XFF,0X80,0X00,0X00,0X00,0X00,
0X00,0X00,0X00,0X00,0X00,0XFF,0XFF,0XF8,0X03,0XFF,0XFF,0XE0,0X00,0X00,0X00,0X00,
0X00,0X00,0X00,0X00,0X03,0XFF,0XFF,0XFE,0X0F,0XFF,0XFF,0XF8,0X00,0X00,0X00,0X00,
0X00,0X00,0X00,0X00,0X07,0XFF,0XFF,0XFF,0XBF,0XFF,0XFF,0XFC,0X00,0X00,0X00,0X00,
0X00,0X00,0X00,0X00,0X0F,0XFF,0X8F,0XFF,0XFF,0XFE,0X3F,0XFE,0X00,0X00,0X00,0X00,
0X00,0X00,0X00,0X00,0X0F,0XFC,0X03,0XFF,0XFF,0XF0,0X07,0XFE,0X00,0X00,0X00,0X00,
0X00,0X00,0X00,0X00,0X0F,0XF8,0X00,0XFF,0XFF,0XE0,0X07,0XFE,0X00,0X00,0X00,0X00,
0X00,0X00,0X00,0X00,0X0F,0XF8,0X00,0X3F,0XFF,0X80,0X03,0XFE,0X00,0X00,0X00,0X00,
0X00,0X00,0X00,0X00,0X0F,0XFC,0X00,0X7F,0XFF,0XC0,0X07,0XFE,0X00,0X00,0X00,0X00,
0X00,0X00,0X00,0X00,0X0F,0XFC,0X01,0XFF,0XFF,0XF0,0X0F,0XFE,0X00,0X00,0X00,0X00,
0X00,0X00,0X00,0X00,0X07,0XFF,0X07,0XFF,0XFF,0XFC,0X1F,0XFE,0X00,0X00,0X00,0X00,
0X00,0X00,0X00,0X00,0X07,0XFF,0XC7,0XFF,0XFF,0XF8,0X7F,0XFC,0X00,0X00,0X00,0X00,
0X00,0X00,0X00,0X00,0X03,0XFF,0XE1,0XFF,0X1F,0XF1,0XFF,0XF8,0X00,0X00,0X00,0X00,
0X00,0X00,0X00,0X00,0X00,0XFF,0XF8,0X7C,0X0F,0XC3,0XFF,0XE0,0X00,0X00,0X00,0X00,
0X00,0X00,0X00,0X00,0X00,0X7F,0XFE,0X10,0X03,0X0F,0XFF,0XC0,0X00,0X00,0X00,0X00,
0X00,0X00,0X00,0X00,0X00,0X1F,0XFF,0X00,0X00,0X3F,0XFF,0X00,0X00,0X00,0X00,0X00,
0X00,0X00,0X7E,0X00,0X00,0X07,0XFF,0XC0,0X00,0X7F,0XFC,0X00,0X00,0X0F,0X80,0X00,
0X00,0X07,0XFF,0XF0,0X00,0X63,0XFF,0XF0,0X01,0XFF,0XF0,0XC0,0X01,0XFF,0XFC,0X00,
0X00,0X3F,0XFF,0XFC,0X01,0XF8,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XFF,0XE1,0XE0,0X07,0XFF,0XFF,0X00,
0X00,0X07,0XFF,0XE0,0X00,0X43,0XFF,0XE0,0X01,0XFF,0XF8,0XC0,0X00,0XFF,0XF8,0X00,
0X00,0X00,0X00,0X00,0X00,0X0F,0XFF,0XC0,0X00,0X7F,0XFC,0X00,0X00,0X00,0X00,0X00,
0X00,0X00,0X00,0X00,0X00,0X1F,0XFF,0X00,0X00,0X3F,0XFF,0X00,0X00,0X00,0X00,0X00,
0X00,0X00,0X00,0X00,0X00,0X7F,0XFC,0X30,0X03,0X0F,0XFF,0XC0,0X00,0X00,0X00,0X00,
0X00,0X00,0X00,0X00,0X01,0XFF,0XF8,0XFC,0X0F,0XC3,0XFF,0XE0,0X00,0X00,0X00,0X00,
0X00,0X00,0X00,0X00,0X03,0XFF,0XE1,0XFF,0X3F,0XF1,0XFF,0XF8,0X00,0X00,0X00,0X00,
0X00,0X00,0X00,0X00,0X07,0XFF,0X87,0XFF,0XFF,0XF8,0X7F,0XFC,0X00,0X00,0X00,0X00,
0X00,0X00,0X00,0X00,0X0F,0XFF,0X07,0XFF,0XFF,0XFC,0X1F,0XFC,0X00,0X00,0X00,0X00,
0X00,0X00,0X00,0X00,0X0F,0XFC,0X01,0XFF,0XFF,0XF0,0X0F,0XFE,0X00,0X00,0X00,0X00,
0X00,0X00,0X00,0X00,0X1F,0XF8,0X00,0X7F,0XFF,0XC0,0X07,0XFE,0X00,0X00,0X00,0X00,
0X00,0X00,0X00,0X00,0X1F,0XF8,0X00,0X7F,0XFF,0X80,0X03,0XFE,0X00,0X00,0X00,0X00,
0X00,0X00,0X00,0X00,0X0F,0XF8,0X00,0XFF,0XFF,0XE0,0X07,0XFE,0X00,0X00,0X00,0X00,
0X00,0X00,0X00,0X00,0X0F,0XFC,0X03,0XFF,0XFF,0XF0,0X0F,0XFE,0X00,0X00,0X00,0X00,
0X00,0X00,0X00,0X00,0X0F,0XFF,0X9F,0XFF,0XFF,0XFE,0X7F,0XFC,0X00,0X00,0X00,0X00,
0X00,0X00,0X00,0X00,0X07,0XFF,0XFF,0XFF,0X3F,0XFF,0XFF,0XFC,0X00,0X00,0X00,0X00,
0X00,0X00,0X00,0X00,0X03,0XFF,0XFF,0XFC,0X0F,0XFF,0XFF,0XF0,0X00,0X00,0X00,0X00,
0X00,0X00,0X00,0X00,0X00,0XFF,0XFF,0XF8,0X03,0XFF,0XFF,0XE0,0X00,0X00,0X00,0X00,
0X00,0X00,0X00,0X00,0X00,0X3F,0XFF,0XE0,0X00,0XFF,0XFF,0X80,0X00,0X00,0X00,0X00,
0X00,0X00,0X00,0X00,0X00,0X07,0XFE,0X00,0X00,0X1F,0XFC,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,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
};

flash unsigned char tab2[]={
/*--  调入了一幅图像:移动图标 123456.bmp  --*/
/*--  宽度x高度=128x64  --*/
0X00,0X00,0X00,0X00,0X00,0X00,0X0F,0XFF,0XFF,0XF8,0X00,0X00,0X00,0X00,0X00,0X00,
0X00,0X00,0X00,0X00,0X00,0X0F,0XFF,0XFF,0XFF,0XFF,0XF0,0X00,0X00,0X00,0X00,0X00,
0X00,0X00,0X00,0X00,0X01,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XC0,0X00,0X00,0X00,0X00,
0X00,0X00,0X00,0X00,0X3F,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFC,0X00,0X00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XC0,0X00,0X00,0X00,
0X00,0X00,0X00,0X00,0X3F,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFC,0X00,0X00,0X00,0X00,
0X00,0X00,0X00,0X00,0X03,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XE0,0X00,0X00,0X00,0X00,
0X00,0X00,0X00,0X00,0X00,0X1F,0XFF,0XFF,0XFF,0XFF,0XF8,0X00,0X00,0X00,0X00,0X00,
0X00,0X00,0X00,0X00,0X00,0X00,0X3F,0XFF,0XFF,0XFE,0X00,0X00,0X00,0X00,0X00,0X00,
0X00,0X00,0X00,0X00,0X00,0X00,0X00,0XCF,0XE6,0X00,0X00,0X00,0X00,0X00,0X00,0X00
};
flash unsigned char tab3[]={
/*--  调入了一幅图像:移动图标 1234.bmp  --*/
/*--  宽度x高度=64x64  --*/
0X00,0X00,0X00,0X3F,0XFE,0X00,0X00,0X00,0X00,0X00,0X03,0XFF,0XFF,0XC0,0X00,0X00,
0X00,0X00,0X0F,0XFF,0XFF,0XF8,0X00,0X00,0X00,0X00,0X7F,0XFF,0XFF,0XFE,0X00,0X00,
0X00,0X00,0XFF,0XFF,0XFF,0XFF,0X80,0X00,0X00,0X03,0XFF,0XFF,0XFF,0XFF,0XC0,0X00,
0X00,0X07,0XFF,0XF0,0X07,0XFF,0XF0,0X00,0X00,0X0F,0XFF,0XE0,0X01,0XFF,0XF8,0X00,
0X00,0X1F,0XFF,0X80,0X00,0XFF,0XFC,0X00,0X00,0X7F,0XFF,0X00,0X00,0X7F,0XFE,0X00,
0X00,0X7F,0XFE,0X00,0X00,0X1F,0XFF,0X00,0X00,0XFF,0XFC,0X00,0X78,0X0F,0XFF,0X80,
0X01,0XFF,0XF0,0X01,0XFE,0X07,0XFF,0XC0,0X03,0XFF,0XE0,0X03,0XFF,0X83,0XFF,0XC0,
0X03,0XFF,0XC0,0X0F,0XFF,0XC0,0XFF,0XE0,0X07,0XFF,0X80,0X1F,0XFF,0XE0,0X7F,0XF0,
0X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FC,0X1F,0XF0,0X3E,0X00,0X0F,0X80,0X0F,0XFC,
0X1F,0XF8,0X1F,0X00,0X3F,0X00,0X1F,0XF8,0X0F,0XFC,0X0F,0X80,0X7E,0X00,0X3F,0XF8,
0X0F,0XFE,0X07,0XE1,0XFC,0X00,0XFF,0XF0,0X07,0XFF,0X81,0XFF,0XF8,0X01,0XFF,0XF0,
0X07,0XFF,0XC0,0XFF,0XE0,0X03,0XFF,0XE0,0X03,0XFF,0XE0,0X7F,0XC0,0X07,0XFF,0XE0,
0X01,0XFF,0XF0,0X3F,0X80,0X1F,0XFF,0XC0,0X00,0XFF,0XF8,0X00,0X00,0X3F,0XFF,0X80,
0X00,0XFF,0XFE,0X00,0X00,0X7F,0XFF,0X00,0X00,0X7F,0XFF,0X00,0X00,0XFF,0XFE,0X00,
0X00,0X3F,0XFF,0X80,0X01,0XFF,0XFC,0X00,0X00,0X1F,0XFF,0XC0,0X07,0XFF,0XF8,0X00,
0X00,0X07,0XFF,0XF0,0X0F,0XFF,0XF0,0X00,0X00,0X03,0XFF,0XFC,0X3F,0XFF,0XE0,0X00,
0X00,0X01,0XFF,0XFF,0XFF,0XFF,0X80,0X00,0X00,0X00,0X7F,0XFF,0XFF,0XFE,0X00,0X00,
0X00,0X00,0X1F,0XFF,0XFF,0XFC,0X00,0X00,0X00,0X00,0X03,0XFF,0XFF,0XE0,0X00,0X00,
0X00,0X00,0X00,0X7F,0XFF,0X00,0X00,0X00,0X00,0X00,0X00,0X0B,0XD0,0X00,0X00,0X00
};

flash unsigned char tab4[]={
/*--  调入了一幅图像:联通图标 45678.bmp  --*/
/*--  宽度x高度=64x64  --*/
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,0X00,0X00,0X00,0X00,0X01,0XF0,0X03,0XE0,0X00,0X00,
0X00,0X00,0X07,0XFC,0X0F,0XF8,0X00,0X00,0X00,0X00,0X0F,0XFE,0X1F,0XFC,0X00,0X00,
0X00,0X00,0X1F,0XFF,0X3F,0XFE,0X00,0X00,0X00,0X00,0X1F,0XFF,0XFF,0XFE,0X00,0X00,
0X00,0X00,0X1F,0XBF,0XFF,0X7E,0X00,0X00,0X00,0X00,0X3E,0X1F,0XFC,0X1F,0X00,0X00,
0X00,0X00,0X3E,0X0F,0XFC,0X1F,0X00,0X00,0X00,0X00,0X3E,0X07,0XF8,0X1F,0X00,0X00,
0X00,0X00,0X3E,0X07,0XF8,0X1F,0X00,0X00,0X00,0X00,0X3E,0X0F,0XFC,0X3F,0X00,0X00,
0X00,0X00,0X1F,0X1F,0XFE,0X3E,0X00,0X00,0X00,0X00,0X1F,0X9F,0XFE,0X7E,0X00,0X00,
0X00,0X00,0X0F,0XCF,0X3C,0XFC,0X00,0X00,0X00,0X00,0X0F,0XE6,0X19,0XFC,0X00,0X00,
0X00,0X00,0X07,0XF0,0X13,0XF8,0X00,0X00,0X00,0X00,0X03,0XF0,0X07,0XF0,0X00,0X00,
0X00,0X70,0X01,0XF8,0X07,0XE0,0X03,0X80,0X01,0XFC,0X0C,0XFC,0X0F,0XC8,0X0F,0XE0,
0X07,0XFE,0X0C,0XFE,0X1F,0XCC,0X1F,0XF0,0X07,0XFF,0X1E,0X7F,0X3F,0X9E,0X3F,0XF8,
0X0F,0XFF,0XBF,0X3F,0XFF,0X3F,0X7F,0XFC,0X0F,0XFF,0XFF,0X1F,0XFE,0X3F,0XFF,0XFC,
0X1F,0X8F,0XFE,0X0F,0XFC,0X1F,0XFC,0X7E,0X1F,0X07,0XFC,0X0F,0XF8,0X0F,0XF8,0X3E,
0X1F,0X03,0XF8,0X07,0XF8,0X07,0XF0,0X3E,0X1F,0X03,0XF8,0X07,0XF8,0X07,0XF0,0X3E,
0X1F,0X07,0XFC,0X0F,0XFC,0X0F,0XF8,0X3E,0X1F,0X8F,0XFE,0X1F,0XFC,0X1F,0XFC,0X7E,
0X0F,0XFF,0XFF,0X1F,0XFE,0X3F,0XFF,0XFC,0X0F,0XFF,0XBF,0X3F,0X7F,0X3F,0X7F,0XFC,
0X07,0XFF,0X1E,0X7F,0X3F,0X9E,0X3F,0XF8,0X03,0XFE,0X0C,0XFE,0X1F,0XCC,0X1F,0XF0,
0X01,0XFC,0X01,0XFC,0X0F,0XE8,0X0F,0XE0,0X00,0X00,0X03,0XF8,0X07,0XE0,0X00,0X00,
0X00,0X00,0X03,0XF0,0X07,0XF0,0X00,0X00,0X00,0X00,0X07,0XE4,0X13,0XF8,0X00,0X00,
0X00,0X00,0X0F,0XEE,0X39,0XFC,0X00,0X00,0X00,0X00,0X1F,0XCF,0X7C,0XFC,0X00,0X00,
0X00,0X00,0X1F,0X9F,0XFE,0X7E,0X00,0X00,0X00,0X00,0X3F,0X1F,0XFE,0X3E,0X00,0X00,
0X00,0X00,0X3E,0X0F,0XFC,0X3F,0X00,0X00,0X00,0X00,0X3E,0X07,0XF8,0X1F,0X00,0X00,
0X00,0X00,0X3E,0X07,0XF8,0X1F,0X00,0X00,0X00,0X00,0X3E,0X0F,0XFC,0X1F,0X00,0X00,
0X00,0X00,0X3E,0X1F,0XFC,0X3F,0X00,0X00,0X00,0X00,0X3F,0XBF,0XFF,0X7E,0X00,0X00,
0X00,0X00,0X1F,0XFF,0X7F,0XFE,0X00,0X00,0X00,0X00,0X1F,0XFE,0X3F,0XFC,0X00,0X00,
0X00,0X00,0X0F,0XFE,0X1F,0XFC,0X00,0X00,0X00,0X00,0X07,0XFC,0X0F,0XF8,0X00,0X00,
0X00,0X00,0X01,0XF0,0X03,0XE0,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
};

void main(void)
{  
  delay_ms(200); 
  PORTB = 0xff;
  DDRB  = 0xff;        // PORTB.7输出,作为运行标志
  init_lcd();          // LCD初始化,并清屏   
  LcdClearTXT();       // 文本区RAM清零
  LcdClearBMP();       // 图形区RAM清零
  run = 0;             // 运行标志亮
  while(1)
  {  
    hz_disp();         // 显示汉字或字母    
    LcdClearTXT();     // 文本区RAM清零
    
    lcdfill(0xff);     // 显示全亮
    delay_ms(1000);
    run = ~run;

    Disp_H_Line();     // 显示横条
    delay_ms(1000); 
    run = ~run;

    lcdfill(0xaa);     // 显示竖条
    delay_ms(1000); 
    run = ~run;

    frame();           // 显示边框
    delay_ms(1000); 
    run = ~run;  
    
    img_disp(tab);     // 显示联通图标128*64
    delay_ms(1000); 
    run = ~run;

    img_disp(tab2);    // 显示移动图标128*64
    delay_ms(1000);
    run = ~run;

    img_disp2(tab3);   // 显示移动图标64*64
    img_disp3(tab4);   // 显示联通图标64*64
    delay_ms(1000); 
    run = ~run;   
    
    LcdClearBMP();     // 图形区RAM清零
    
  }       
}  
/*------------------LCD写数据-----------------*/
void LCD_send_byte(unsigned char a)
{
  unsigned char i;  
  for(i=0;i<8;i++)
  { 
    sclk = 0;
    delay_us(2); 
    if(a&0x80)
      sid = 1;
    else
      sid = 0;
    delay_us(2);
    a = a<<1;
    sclk = 1;
    delay_us(2);  
    sclk = 0;
    delay_us(2); 
  } 

/*-------------------------LCD读数据-------------------------*/  
unsigned char LCD_read_byte(void)
{
  unsigned char i,dat,dat2; 
  dat=dat2=0; 
  DDRD  &= ~(1<   PORTD &= ~(1<   delay_us(2); 
  for(i=0;i<8;i++)          // 读高字节
  {    
    dat = dat<<1;
    sclk = 0;
    delay_us(2); 
    sclk = 1;
    delay_us(2);
    if((PIND&(1<     sclk = 0;
    delay_us(2); 
  }     
  for(i=0;i<8;i++)          // 读低字节
  {    
    dat2 = dat2<<1;
    sclk = 0;
    delay_us(2); 
    sclk = 1;
    delay_us(2);
    if((PIND&(1<     sclk = 0;
    delay_us(2); 
  } 
  dat = (dat&0xf0) + (dat2&0x0f);
  DDRD  |= 1<   delay_us(2);  
  return dat;
}
/*--------------检测LCD忙闲---------------*/
void chk_busy(void)

  unsigned char dat;  
  do 
  {
    cs = 1;
    delay_us(2);
    LCD_send_byte(0xfc);
    dat = LCD_read_byte();
    delay_us(2);
    cs = 0;
    delay_us(2); 
  }while(dat&0x80); 
}
/*------------------LCD初始化-----------------*/
void init_lcd(void)

  PORTD = 0xff;
  DDRD  = 0xff;   // PD输出,提供LCD控制信号   
  sclk = 0;
  cs = 0;
  rst = 0;
  delay_ms(2);
  rst = 1;  
  delay_ms(10);
  psb = 0;       // 串行 
  delay_us(2);
  wr_comm(0x30); // 基本指令,8位数据模式
  wr_comm(0x0C); // 显示开,游标关,反白关
  wr_comm(0x01); // 清除显示,并且设定地址指针为00H
  wr_comm(0x06); // 指定在资料的读取及写入时,设定游标的移动方向及指定显示的移位       
}
/*------------写命令到LCD--------------*/
void wr_comm(unsigned char comm)
{  
  unsigned char temp;  
  chk_busy();
  cs = 1;
  delay_us(2);
  LCD_send_byte(0xf8);   // 写命令
  temp = comm&0xf0;
  LCD_send_byte(temp);  // 写高字节
  temp=(comm&0x0f)<<4;
  LCD_send_byte(temp);  // 写低字节
  delay_us(2);
  cs = 0;
}
/*------------写数据到LCD--------------*/
void wr_data(unsigned char dat)

  unsigned char temp;       
  chk_busy();
  cs = 1;
  delay_us(2);
  LCD_send_byte(0xfa);   // 写数据
  temp = dat&0xf0;
  LCD_send_byte(temp);   // 写高字节
  temp = (dat&0x0f)<<4;
  LCD_send_byte(temp);   // 写低字节
  delay_us(2);         
  cs = 0;
}  
/*-------向LCD写一个字符串,长度64字符之内---------- */
void wr_str(unsigned char flash *s)
{
   while(*s>0)
   {
      wr_data(*s);
      s++;
   }
}
/*------------显示汉字或字母--------------*/
void hz_disp(void)
{  
   wr_comm(0x30); // 基本指令,8位数据模式
   wr_comm(0x01); // 清除显示,并且设定地址指针为00H

   /*-显示4行汉字-*/
   wr_comm(0x80);     // 第 1 行
     wr_str(ex1); 
   wr_comm(0x90);     // 第 2 行
     wr_str(ex2);
   wr_comm(0x88);     // 第 3 行
     wr_str(ex3);
   wr_comm(0x98);     // 第 4 行
     wr_str(ex4);  
   run = ~run;
   delay_ms(3000);    // 延时
   wr_comm(0x01);     // 清除显示
   /*-显示4行汉字-*/
   wr_comm(0x80);
     wr_str(ex5);
   wr_comm(0x90);
     wr_str(ex6);
   wr_comm(0x88);
     wr_str(ex7);
   wr_comm(0x98);
     wr_str(ex8);  
    run = ~run;
   delay_ms(3000);
   wr_comm(0x01);     // 清除显示
   /*-显示2行字母-*/
   wr_comm(0x80);
     wr_str(ex9);  
   wr_comm(0x88);
     wr_str(ex10);
    run = ~run;
   delay_ms(3000);  
   wr_comm(0x01);     // 清除显示
}   
/*--------------------------- 显示图片,128*64 --------------------------- */
void img_disp(unsigned char flash *img)
{
  unsigned char i,x,y;
  unsigned int j=0;
  for(i=0;i<9;i=i+8)       // i=0,控制上半屏,i=8,控制下半屏
  {
    for(y=0;y<32;y++)      // y控制行地址
    {
      for(x=0;x<8;x++)     // x控制列地址
      {
        wr_comm(0x36);     // 功能设置:8位控制界面,扩充指令集,绘图显示开
        wr_comm(0x80+y);   // 行地址
        wr_comm(0x80+x+i); // 列地址  x+i=0~7, 上半屏,x+i=8~15,下半屏
        wr_data(img[j++]); // 高字节
        wr_data(img[j++]); // 低字节
        wr_comm(0x30);     // 功能设置:8位控制界面,基本指令集,绘图显示关
      }
    }
  }
}
/*------------------------ 显示图片,64*64 ------------------------------ */
void img_disp2(unsigned char flash *img)   // 左半屏
{
  unsigned char i,x,y;
  unsigned int j=0;
  for(i=0;i<9;i=i+8)       // i=0,控制上半屏,i=8,控制下半屏
  {
    for(y=0;y<32;y++)      // y控制行地址
    {
      for(x=0;x<4;x++)     // x控制列地址
      {
        wr_comm(0x36);     // 功能设置:8位控制界面,扩充指令集,绘图显示开
        wr_comm(0x80+y);   // 行地址
        wr_comm(0x80+x+i); // 列地址  x+i=0~7, 上半屏,x+i=8~15,下半屏
        wr_data(img[j++]); // 高字节
        wr_data(img[j++]); // 低字节
        wr_comm(0x30);     // 功能设置:8位控制界面,基本指令集,绘图显示关
      }
    }
  }
}
/*------------------------- 显示图片,64*64 ----------------------------- */
void img_disp3(unsigned char flash *img)    //  右半屏
{
  unsigned char i,x,y;
  unsigned int j=0;
  for(i=0;i<9;i=i+8)       // i=0,控制上半屏,i=8,控制下半屏
  {
    for(y=0;y<32;y++)      // y控制行地址
    {
      for(x=4;x<8;x++)     // x控制列地址
      {
        wr_comm(0x36);     // 功能设置:8位控制界面,扩充指令集,绘图显示开
        wr_comm(0x80+y);   // 行地址
        wr_comm(0x80+x+i); // 列地址  x+i=0~7, 上半屏,x+i=8~15,下半屏
        wr_data(img[j++]); // 高字节
        wr_data(img[j++]); // 低字节
        wr_comm(0x30);     // 功能设置:8位控制界面,基本指令集,绘图显示关
      }
    }
  }
}
/*-------  整屏填充,全亮,或者竖条  -------- */
void lcdfill(unsigned char disdata)  
{
  unsigned char x,y;
  for(y=0;y<32;y++)
  {
    for(x=0;x<16;x++)
    {
      wr_comm(0x36);
      wr_comm(y+0x80);     //行地址
      wr_comm(x+0x80);     //列地址
      wr_comm(0x30);
      wr_data(disdata);
      wr_data(disdata);
    }
  }
}
/*--------------- 显示横条 -----------------*/
void Disp_H_Line()
{  unsigned char x,y;
   unsigned char k=0x00;
   for(y=0;y<32;y++)
   { k=~k;
     for(x=0;x<16;x++)
     {
       wr_comm(0x36);
       wr_comm(y+0x80);     //行地址
       wr_comm(x+0x80);     //列地址
       wr_comm(0x30);
       wr_data(k);
       wr_data(k);
     }
   }
}
/*---------------- 显示边框 ----------------*/
void frame()
{
  unsigned char x,y;
  lcdfill(0x00);
  for(x=0;x<9;x+=8)
  {
    for(y=0;y<32;y++)
    {
      wr_comm(0x36);
      wr_comm(y+0x80);      //行地址
      wr_comm(x+0x80);      //列地址
      wr_comm(0x30);
      wr_data(0x80);
      wr_data(0x00);

      wr_comm(0x36);
      wr_comm(y+0x80);      //行地址
      wr_comm(x+0x87);      //列地址
      wr_comm(0x30);
      wr_data(0x00);
      wr_data(0x01);
    }
  }
  for(y=0;y<2;y++)
  {
    for(x=0;x<8;x++)
    {
      wr_comm(0x36);
      wr_comm(y*31+0x80);      //行地址
      wr_comm(x+0x80+8*y);     //列地址
      wr_comm(0x30);
      wr_data(0xff);
      wr_data(0xff);
    }
  }
}   
/*----------------文本区清RAM函数----------------*/
void LcdClearTXT(void)
{
     unsigned char i;
     wr_comm(0x30);      // 8BitMCU,基本指令集合
     wr_comm(0x80);      // AC归起始位
     for(i=0;i<64;i++)
       wr_data(0x20);

/*-----------------图形区清RAM函数-----------------*/
void LcdClearBMP(void)
{
     unsigned char i,j;
     wr_comm(0x34);        // 8Bit扩充指令集,即使是36H也要写两次
     wr_comm(0x36);        // 绘图ON,基本指令集里面36H不能开绘图
     for(i=0;i<32;i++)     // 12864实际为256x32
     {
       wr_comm(0x80|i);    // 行位置
       wr_comm(0x80);      // 列位置
       for(j=0;j<32;j++)   // 256/8=32 byte
         wr_data(0);
     }
}

关键字:带字库  串行方式显示  AVR程序 引用地址:12864(带字库)串行方式显示汉字和字库-CVAVR程序

上一篇:164驱动8位LED显示 CVAVR程序
下一篇:12864(带字库)并行方式显示汉字和图形-CVAVR程序

推荐阅读最新更新时间:2024-03-16 15:18

基于AVR的4*4矩阵键盘扫描与LED显示程序
/************** 此程序在别人的基础上进行了一些修改,能应用到我的开发板中, 并与我自制的外接按键和LED灯配合使用,在此感谢原创者!!! 硬件:M16 作用:当按下按键时显示相对应的按键控制的LED灯 频率:8.000000MHZ 开发板:EasyAVR M16 v12 编译软件:ICCAVR6.31A 下载软件:AVRstudio4.14 编写人:伍建忠 编写日期:2011.10.14 修改日期: ************/ #include iom16v.h #include macros.h #define uchar unsigned char #define uint unsigned int uint
[单片机]
基于74HC595 74HC165 的AVR单片机程序例子
硬件说明:ATmega48/88/168的PB5是SPI时钟输出,接74HC595/74HC165的移位时钟输入端;PB4是SPI的MISO数据输人,接74HC165的数据输出;PB3是SPI的MOSI数据输出,接74HC595的串行数据输入端SER;PB2接74HC595/74HC165的锁存时钟输入端。 程序1:本例子是用硬件SPI接口循环发送一个变量到74HC595,并且在数据发送完毕后通过单片机的另外一个IO接口PB2输出一个 锁存 脉冲 ,使74HC595把移位寄存器的数据输出到锁存寄存器,并驱动8个LED输出,实现来回流水的效果。 //本程序在本站的 M8 V2.0 实验板 通过 // CodeWizardAVR
[单片机]
AVR单片机相位修正PWM定时器0发生模式试验程序
/*AVR相位修正PWM定时器0发生模式*/ /*PWM波的产生机理是定时器0的TCNT0由0到255,在由255到0,不断地计数,当在0-255计数时TCNT0=OCR0时在OC0引脚上出现低电平,*/ /*当在255-0计数时TCNT0=OCR0时在OC0引脚上出现高电平,当由0加到255,再由255减到0时,产生溢出中断,可以再终端服务中修改OCR0的值,以改变占空比,比用引脚模拟要准确*/ /*另外值得说的是相位修正PWM很适合用在电机控制的场合,他比快速PWM慢,因此它的最大频率要比快速PWM低的多*/ /* 相位修正PWM实验 20110416 天津第四项目部宿舍 王均伟 */ #include iom16v.
[单片机]
12864LCD的显示
;模 块 名:ST7920 控制器 NS12864R ;功能描述:库内汉字的显示 ;***************************; ; NS12864显示程序(库内汉字) ; ;***************************; ORG 0000H SJMP START RS EQU P3.2 ;并行的指令/数据选择信号 RW EQU P3.3 ;并行的读写选择信号 E EQU P3.4 ;并行的使能信号 PSB EQU P3.5 ;并/串行接口选择:H-并行;L-串行 COM EQU 20H ;指令代码单元 DAT EQU 21H ;数据单
[单片机]
LCD12864万年历单片机程序+实物制作+Proteus仿真
制作出来的LCD12864万年历实物图如下: LCD12864万年历仿真原理图如下(proteus仿真工程文件可到本帖附件中下载) 电路原理图如下: 单片机源程序如下: *----------------------------------------------- 名称:12864字库液晶显示 内容:通过显示字符、数字、汉字和图片测试液晶基本功能 ------------------------------------------------*/ #include reg52.h #include intrins.h #include delay.h sbit RS = P3^5; sbit RW = P3
[单片机]
LCD<font color='red'>12864</font>万年历单片机<font color='red'>程序</font>+实物制作+Proteus仿真
STM32 驱动12864液晶显示汉字、图片、画点、横线、竖线、斜线
我做本实验的软件平台为MDK软件,选用STM32VET6,12864液晶屏5v供电采用并行接法。之前本来想网上找一个现成的程序实验一下,但都没找到合适的,于是就自己编写了一个,最终可在12864液晶屏上面任意位置显示任意内容。在此贴出整个工程文件,希望对大家有帮助! 本实验的整个工程文件可在此处下载:http://download.csdn.net/detail/u010173859/5908815 /********************************************************************************** * 文件名 :main.c * 描述 :利用1286
[单片机]
AVR单片机硬件I2C接口驱动程序
今天上午写了atmega16的I2C硬件接口程序,程序不难,只是给初学的朋友一个思路,不过通过和51的软件模拟I2C程序比较发现,AVR的I2C硬件接口使程序更简单了, 程序功能:先由atmega16向EEPROM中某地址写数字71,然后再从EEPROM里读出来显示到数码管上; #include iom16v.h #include avrdef.h unsigned char const duacode ={0x3f,0x06,0x5b,0x4f, 0x66,0x6d,0x7d,0x07, 0x7f,0x6f,0x77,0x7c,
[单片机]
<font color='red'>AVR</font>单片机硬件I2C接口驱动<font color='red'>程序</font>
LCD12864(KS0108)驱动程序 显示汉字-字符
仿真原理图如下 #include reg52.h #include intrins.h #include string.h #include hanzi.h //汉字库头文件 #include shuzi.h //字符库头文件 #define uchar unsigned char #define uint unsigned int // lcd12864(ks0108) #define LCD_DATA P2 //LCD8位并行数据口 sbit LCD_RS=P0^5; //寄存器选择 sbit LCD_RW=P0^6; //读/写选择 sbit LCD_EN=P0^7;
[单片机]
LCD<font color='red'>12864</font>(KS0108)驱动<font color='red'>程序</font> <font color='red'>显示</font>汉字-字符
小广播
添点儿料...
无论热点新闻、行业分析、技术干货……
设计资源 培训 开发板 精华推荐

最新单片机文章
何立民专栏 单片机及嵌入式宝典

北京航空航天大学教授,20余年来致力于单片机与嵌入式系统推广工作。

换一换 更多 相关热搜器件
更多每日新闻
电子工程世界版权所有 京B2-20211791 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号 Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved