微波EDA网,见证研发工程师的成长!
首页 > 硬件设计 > 嵌入式设计 > PIC16F877A驱动12864液晶

PIC16F877A驱动12864液晶

时间:11-09 来源:互联网 点击:

for(j=32;j<64;j++)
{
send_cmd(0x80+j-32) ;
send_cmd(0x88) ;
for(i=0;i<8;i++)
{
send_byte(0x00) ;
send_byte(0x00) ;
}
}
send_cmd(0x36) ;
send_cmd(0x30);
send_cmd(0x0c) ;//close blind cursor
}
void str_disp(const char *data,uchar X,uchar Y)
{
X=X&0x07 ;//dont outweigh the numbers of one line
Y=Y&0x03 ;
switch(Y)
{
case 0:
Y=0x80 ;
break ;
case 1 :
Y=0x90 ;
break ;
case 2 :
Y=0x88 ;
break ;
case 3 :
Y=0x98 ;
break ;
defualt :
break ;
}
send_cmd(Y+X) ;
while(*data!=/0)
{
send_byte(*data++) ;
}
}

void chn_disp(const char *data,uchar X,uchar Y,uchar count)
{
uchar i ;
switch(Y)
{
case 0:
Y=0x80 ;
break ;
case 1 :
Y=0x90 ;
break ;
case 2 :
Y=0x88 ;
break ;
case 3 :
Y=0x98 ;
break ;
defualt :
break ;
}

send_cmd(Y+X) ;
for(i=0;isend_byte(*data++) ;
}
void locate_xy(uchar X,uchar Y)
{
X=X&0x07 ;
Y=Y&0x03 ;
switch(Y)
{
case 0:
Y=0x80 ;
break ;
case 1 :
Y=0x90 ;
break ;
case 2 :
Y=0x88 ;
break ;
case 3 :
Y=0x98 ;
break ;
defualt :
break ;
}
send_cmd(Y+X) ;
}
void con_disp(uchar x0,uchar y0,uchar x1,uchar y1)
{
;
}
void lcd_rol()
{
uchar i;
send_cmd(0x03) ;
for(i=0;i<64;i++)
{
send_cmd(0xC0+i) ;

DelayMs(200) ;
}
}
void clr_ram()
{
send_cmd(0x01) ;
}

下面是测试程序

#include
#include

#include "main.h"
#include "t232.h"
#include "lcd12864.h"
t232_frame tframe ;
void interrupt main_int()
{
t232_int(&tframe) ;
}
void init_all()
{
asm("clrwdt");
init_232() ;
init_lcd() ;
init_t232_frame(&tframe) ;

}
const uchar tab5[]={
0X00,0X03,0X80,0X00,0X00,0X0F,0XE0,0X00,0X00,0X3F,0XF8,0X00,0X60,0XFF,0XFE,0X00,
0X40,0XFF,0XF8,0X00,0X40,0XCF,0XE0,0X00,0X47,0XFF,0XBC,0X3E,0X44,0X01,0X60,0X60,
0X44,0X00,0X00,0X40,0X44,0X44,0X20,0X44,0X44,0X44,0X60,0X44,0X44,0X44,0X40,0X44,
0X44,0X44,0X04,0X04,0X00,0X40,0X00,0X40,0X06,0X62,0X00,0X70,0X3F,0XFB,0X1F,0XCC,
0XFF,0XFF,0X7F,0XE0,0XFF,0XF8,0X1F,0XF0,0XFF,0XE0,0X7F,0XF0,0XFF,0X80,0XFF,0XC0,
0XCF,0X00,0XCE,0X00,0XC3,0X00,0XC7,0X00,0XF0,0X00,0XC3,0X00,0XFC,0X00,0XC0,0X00,
0XCC,0X00,0XE0,0X00,0XC0,0X00,0X73,0X00,0XC0,0X01,0XFF,0X00,0XC0,0X07,0XFE,0X03,
0XF0,0X1F,0XF8,0X0F,0XFC,0X7F,0XFE,0X3F,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,
};

void main()
{
const uchar data0[]="山东轻工业学院" ;
const uchar data1[]="欢迎你!" ;
const uchar *data2="Waiting...." ;
const uchar *temp ;
uchar i ,j;
init_all() ;

//str_disp("Waiting.......",0,2) ;
for(j=0;j<2;j++)
{
i=1 ;
send_cmd(0x8A) ;
temp=data2 ;
while(*temp!=/0)
{
send_byte(*temp++) ;
DelayMs(50) ;
}
DelayMs(500) ;
DelayMs(500) ;
clr_ram() ;
DelayMs(10) ;
}
clr_ram() ;
DelayMs(100) ;
chn_disp("山东轻工业学院",0,0,7) ;
chn_disp(data1,2,1,4) ;
//chn_disp("下一步",5,3,3) ;
str_disp("NEXT",5,3) ;
while(1)
{
locate_xy(5,3) ;
send_cmd(0x0E) ;
DelayUs(50) ;
locate_xy(6,3) ;
send_cmd(0x0E) ;
DelayUs(50) ;
}
while(1)
{
;
}
}

Copyright © 2017-2020 微波EDA网 版权所有

网站地图

Top