当前位置:首页 > 单片机 > 单片机
[导读]#include "pic.h" #define RS RC0 #define RW RC1 #define E RC2 #define PSB RC3 #define RST RC4 //PORTD=DATA; unsigned char COUNT3,COUNT2,COUNT1,COUNT,LCD_X,LCD_Y,LCD_DATA1,LCD_DATA2,LCD_DATA,F3,R

#include "pic.h"
#define RS RC0
#define RW RC1
#define E RC2
#define PSB RC3
#define RST RC4
//PORTD=DATA;
unsigned char COUNT3,COUNT2,COUNT1,COUNT,LCD_X,LCD_Y,LCD_DATA1,LCD_DATA2,LCD_DATA,F3,R1,F0;
const unsigned char TU_TAB1[]={
// 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1
0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,
0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,
0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,
0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,
0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,
0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3F,0xFF,0xF0,0x00,0x01,
0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x40,0x00,0x18,0x00,0x01,
0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xBF,0xFF,0xDC,0x00,0x01,
0x80,0x00,0x1F,0xFF,0xFF,0x00,0x00,0x00,0x00,0x00,0x00,0xBF,0xFF,0xBC,0x00,0x01,
0x80,0x00,0x30,0x00,0x01,0x80,0x00,0x00,0x00,0x00,0x01,0x7F,0xFF,0xB8,0x00,0x01,
0x80,0x00,0x30,0x00,0x00,0x80,0x00,0x00,0x00,0x00,0x01,0x7F,0xFF,0x78,0x00,0x01,
0x80,0x00,0x19,0xFF,0xFE,0xC0,0x00,0x00,0x00,0x00,0x02,0xFF,0xFF,0x70,0x00,0x01,
0x80,0x00,0x18,0x00,0x00,0x40,0x00,0x00,0x00,0x00,0x02,0xFF,0xFE,0xF0,0x00,0x01,
0x80,0x00,0x0C,0x01,0xFF,0x60,0x00,0x00,0x00,0x00,0x05,0xFF,0xFE,0xE0,0x00,0x01,
0x80,0x00,0x0C,0x7F,0xD0,0x20,0x00,0x00,0x00,0x00,0x05,0xFF,0xFD,0xE0,0x00,0x01,
0x80,0x00,0x06,0x00,0x0F,0xB0,0x00,0x00,0x00,0x00,0x0B,0xFF,0xFD,0xC0,0x00,0x01,
0x80,0x00,0x06,0x03,0xFC,0x10,0x00,0x00,0x00,0x00,0x0B,0xFF,0xFB,0xC0,0x00,0x01,
0x80,0x00,0x03,0x1F,0x00,0x18,0x00,0x00,0x00,0x00,0x17,0xFF,0xFB,0x80,0x00,0x01,
0x80,0x00,0x03,0x00,0x00,0x08,0x00,0x00,0x00,0x00,0x17,0xFF,0xF7,0x80,0x00,0x01,
0x80,0x00,0x01,0x80,0x00,0x0C,0x00,0x00,0x00,0x00,0x17,0xFF,0xF7,0x00,0x00,0x01,
0x80,0x00,0x01,0x80,0x00,0x04,0x00,0x00,0x00,0x00,0x09,0xFF,0xEF,0x00,0x00,0x01,
0x80,0x00,0x00,0xC0,0x00,0xF6,0x00,0x00,0x00,0x00,0x06,0x7F,0xEE,0x00,0x00,0x01,
0x80,0x00,0x00,0xC0,0x03,0xC2,0x00,0x00,0x00,0x00,0x01,0x9F,0xDE,0x00,0x00,0x01,
0x80,0x00,0x00,0x60,0x00,0x3B,0x00,0x00,0x00,0x00,0x00,0x67,0xDF,0x00,0x00,0x01,
0x80,0x00,0x00,0x60,0x00,0xE3,0x00,0x00,0x00,0x00,0x00,0x19,0xBF,0x00,0x00,0x01,
0x80,0x00,0x00,0x30,0x03,0x8E,0x00,0x00,0x00,0x00,0x00,0x06,0x3F,0x00,0x00,0x01,
0x80,0x00,0x00,0x30,0x06,0x3C,0x00,0x00,0x00,0x00,0x00,0x01,0xFF,0x00,0x00,0x01,
0x80,0x00,0x00,0x18,0x00,0xF0,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0x00,0x00,0x01,
0x80,0x00,0x00,0x18,0x03,0xC0,0x00,0x00,0x00,0x00,0x00,0x0F,0x7F,0x80,0x00,0x01,
0x80,0x00,0x00,0x0C,0x0F,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x1F,0xC0,0x00,0x01,
0x80,0x00,0x00,0x0C,0x3C,0x00,0x00,0x00,0x00,0x00,0x00,0x40,0x07,0xE0,0x00,0x01,
0x80,0x00,0x00,0x06,0xF0,0x00,0x00,0x00,0x00,0x00,0x00,0xE0,0x1F,0xE0,0x00,0x01,
0x80,0x00,0x00,0x07,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0xF8,0x3F,0xC0,0x00,0x01,
0x80,0x00,0x00,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7E,0xFF,0x00,0x00,0x01,
0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x1F,0xFC,0x00,0x00,0x01,
0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x07,0xF0,0x00,0x00,0x01,
0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0xC0,0x00,0x00,0x01,
0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,
0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,
0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,
0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,
0x80,0x05,0x40,0x88,0x04,0x01,0x08,0x00,0x00,0x0A,0x81,0x10,0x04,0x00,0x20,0x01,
0x80,0x79,0x21,0x08,0x02,0x21,0x49,0x00,0x00,0xF2,0x42,0x10,0x04,0x47,0x10,0x01,
0x80,0x09,0x07,0xDF,0x7F,0xF7,0xAA,0x00,0x00,0x12,0x0F,0xBE,0x7F,0xE5,0xFE,0x01,
0x80,0x7F,0xF4,0x51,0x08,0x81,0x2C,0x00,0x00,0xFF,0xE8,0xA2,0x44,0x47,0x00,0x01,
0x80,0x09,0x04,0x61,0x08,0x81,0x7F,0x00,0x00,0x12,0x08,0xC2,0x7F,0xC5,0x4A,0x01,
0x80,0x0B,0x24,0x51,0x08,0x83,0x81,0x00,0x00,0x16,0x48,0xA2,0x44,0x45,0x6A,0x01,
0x80,0x1D,0x47,0xC9,0x05,0x05,0x01,0x00,0x00,0x3A,0x8F,0x92,0x44,0x47,0x52,0x01,
0x80,0x68,0x84,0x49,0x05,0x05,0x7F,0x00,0x00,0xD1,0x08,0x92,0x7F,0xC5,0x6A,0x01,
0x80,0x09,0x94,0x41,0x02,0x01,0x01,0x00,0x00,0x13,0x28,0x82,0x44,0x05,0x4A,0x01,
0x80,0x0E,0x57,0xC1,0x0D,0x81,0x01,0x00,0x00,0x1C,0xAF,0x82,0x04,0x29,0x42,0x01,
0x80,0x38,0x34,0x4E,0x70,0x71,0x7F,0x00,0x00,0x70,0x68,0x9C,0x03,0xEB,0x7E,0x01,
0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,
0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,
0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,
0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,
0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,
0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,
0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,
0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,
0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,
0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,
0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF
};

//*************delay_ms********************************
void delay_10us(unsigned char x)
{
while(x--);
}
void delay_ms(unsigned char cnt)
{
unsigned char i;
do {
i = 4;
do {
delay_10us(39);
} while(--i);
} while(--cnt);
}

//***********检查是否LCD忙碌的子程序**********************
void check_busy(void)
{
TRISD=0xff;//在此处设为输入。
PORTD=0xff;
RS=0;
RW=1;
while (1)
{
NOP();NOP();NOP();
E =1;
NOP();NOP();NOP();
if (RD7==0) break;
NOP();NOP();NOP();
E =0;
}
E =0;
TRISD=0X00;//还原为输出。
RC7=!RC7;
//delay_ms(50);
}
//**********数据写命令***************************
void send_com(unsigned char command )
{
check_busy();
RS=0;
RW=0;
PORTD=command;
E =1;
NOP();
NOP();
E =0;
}
//**********LCD初始化时的送命令******************
void send_com_init(unsigned char command_init )
{
RS=0;
RW=0;
PORTD=command_init;
E =1;
NOP();
NOP();
E =0;
}
//**********写数据***************************
void send_data(unsigned char data )
{
check_busy();
RS=1;
RW=0;
PORTD=data;
E =1;
NOP();
NOP();
E =0;
}
//***********读数据****************************
unsigned char read_data(void)
{
unsigned char read_data;
check_busy();
TRISD=0XFF;
RS=1;
RW=1;
E =1;
NOP();
read_data=PORTD;
E =0;
TRISD=0x00;//还原为输出。
return (read_data);
}
//***********清屏*****************************
void clear_LCD(void)
{
send_com(0x01);
send_com(0x34);
send_com(0x30);
}
//**********LCD初始化************************
void initial_LCD(void)
{
PSB=1;
RST=0;//Reset.
NOP();
NOP();
RST=1;
NOP();
delay_10us(10);
send_com_init(0x30);//30H--基本指令操作
delay_10us(4);
send_com_init(0x0c);//开显示,关光标,不闪烁。
delay_10us(10);
send_com_init(0x01);//清除显示
delay_ms(10);
send_com_init(0x06);//指定在资料写入或读取时,光标的移动方向,DDRAM的地址计数器(AC)加1。

}
//**********写准备***************************
void WR_ZB(void)
{
send_com(0x34);
send_com(LCD_Y);
send_com(LCD_X);
send_com(0x30);
}
//*********取数送显示******************************
void QUSHU(const unsigned char *shu)
{
for (;COUNT!=0;COUNT--)
{
send_data(*shu++);
delay_ms(80);
}
}
//*********Flash******************************
void flash(void)
{
send_com(0x08);//关闭显示
delay_ms(250);
send_com(0x0c);//开显示,关光标,不闪烁。
delay_ms(250);
send_com(0x08);//关闭显示
delay_ms(250);
send_com(0x0c);//开显示,关光标,不闪烁。
delay_ms(250);
send_com(0x08);//关闭显示
delay_ms(250);
}
//**********显示图形子程序*********************
void PHO_DISP(const unsigned char *s)
{
COUNT3=0X02;
LCD_X=0X80;
for (;COUNT3!=0;COUNT3--)
{
LCD_Y=0X80;
COUNT2=0X20;//32
for (;COUNT2!=0;COUNT2--)
{
COUNT1=0X10;//16
WR_ZB();
for (;COUNT1!=0;COUNT1--)
{
send_data(*s++);

}
LCD_Y+=1;
}
LCD_X=0X88;
}
send_com(0x36);
send_com(0x30);
}
//******************显示点阵子程序************
void LAT_DISP(void)
{
COUNT3=0X02;
LCD_X=0X80;
for (;COUNT3!=0;COUNT--)
{
LCD_Y=0X80;
F0=0;
COUNT2=0X20;
for (;COUNT2!=0;COUNT--)
{
COUNT1=0X10;
WR_ZB();
if (F0!=0)
{
LCD_DATA=LCD_DATA2;
}
else LCD_DATA=LCD_DATA1;
for (;COUNT1!=0;COUNT1--)
{
send_data(LCD_DATA);
}
LCD_Y+=1;
F0=!F0;
}
LCD_X=0X88;
}

send_com(0x36);
send_com(0x30);
}

void main(void)
{
TRISC=0X00;
TRISD=0X00;
PORTD=0X00;
PORTC=0X00;
initial_LCD();
while (1)
{
clear_LCD();
PHO_DISP(TU_TAB1);//显示图形
while (1);
}
}

本站声明: 本文章由作者或相关机构授权发布,目的在于传递更多信息,并不代表本站赞同其观点,本站亦不保证或承诺内容真实性等。需要转载请联系该专栏作者,如若文章内容侵犯您的权益,请及时联系本站删除。
换一批
延伸阅读

9月2日消息,不造车的华为或将催生出更大的独角兽公司,随着阿维塔和赛力斯的入局,华为引望愈发显得引人瞩目。

关键字: 阿维塔 塞力斯 华为

加利福尼亚州圣克拉拉县2024年8月30日 /美通社/ -- 数字化转型技术解决方案公司Trianz今天宣布,该公司与Amazon Web Services (AWS)签订了...

关键字: AWS AN BSP 数字化

伦敦2024年8月29日 /美通社/ -- 英国汽车技术公司SODA.Auto推出其旗舰产品SODA V,这是全球首款涵盖汽车工程师从创意到认证的所有需求的工具,可用于创建软件定义汽车。 SODA V工具的开发耗时1.5...

关键字: 汽车 人工智能 智能驱动 BSP

北京2024年8月28日 /美通社/ -- 越来越多用户希望企业业务能7×24不间断运行,同时企业却面临越来越多业务中断的风险,如企业系统复杂性的增加,频繁的功能更新和发布等。如何确保业务连续性,提升韧性,成...

关键字: 亚马逊 解密 控制平面 BSP

8月30日消息,据媒体报道,腾讯和网易近期正在缩减他们对日本游戏市场的投资。

关键字: 腾讯 编码器 CPU

8月28日消息,今天上午,2024中国国际大数据产业博览会开幕式在贵阳举行,华为董事、质量流程IT总裁陶景文发表了演讲。

关键字: 华为 12nm EDA 半导体

8月28日消息,在2024中国国际大数据产业博览会上,华为常务董事、华为云CEO张平安发表演讲称,数字世界的话语权最终是由生态的繁荣决定的。

关键字: 华为 12nm 手机 卫星通信

要点: 有效应对环境变化,经营业绩稳中有升 落实提质增效举措,毛利润率延续升势 战略布局成效显著,战新业务引领增长 以科技创新为引领,提升企业核心竞争力 坚持高质量发展策略,塑强核心竞争优势...

关键字: 通信 BSP 电信运营商 数字经济

北京2024年8月27日 /美通社/ -- 8月21日,由中央广播电视总台与中国电影电视技术学会联合牵头组建的NVI技术创新联盟在BIRTV2024超高清全产业链发展研讨会上宣布正式成立。 活动现场 NVI技术创新联...

关键字: VI 传输协议 音频 BSP

北京2024年8月27日 /美通社/ -- 在8月23日举办的2024年长三角生态绿色一体化发展示范区联合招商会上,软通动力信息技术(集团)股份有限公司(以下简称"软通动力")与长三角投资(上海)有限...

关键字: BSP 信息技术
关闭
关闭