专家
公告
财富商城
电子网
旗下网站
首页
问题库
专栏
标签库
话题
专家
NEW
门户
发布
提问题
发文章
51单片机
求分享ST7036的串口程序
2019-07-15 23:27
发布
×
打开微信“扫一扫”,打开网页后点击屏幕右上角分享按钮
站内问答
/
51单片机
7056
1
1225
不会写程序啊啊啊啊。求指点
友情提示:
此问题已得到解决,问题已经关闭,关闭后问题禁止继续编辑,回答。
该问题目前已经被作者或者管理员关闭, 无法添加新回复
1条回答
幸福DORAMON
1楼-- · 2019-07-16 04:28
本帖最后由 幸福DORAMON 于 2013-8-10 08:29 编辑
/********************************************************;
;* IC : ST7036 *;
;* MCU type : W78E52B(8K ROM) *;
;* Data : 4Line mode *;
;********************************************************/
#include<reg51.h>
#include<intrins.h>
#define uint unsigned int
#define uchar unsigned char
//========================================================
sbit RES=P3^1;
sbit CS1=P3^3;
sbit A0=P3^0;
sbit SCL=P1^0;
sbit SDI=P1^1;
sbit key1=P3^4;
//========================================================
void init(); //初始化
void font1(); //字形1
void font2(); //字形2
void font3(); //字形3
void d_icon();
void c_icon();
void write_cgram();
void d_cgram(int p);
void write_com(int para);
void write_data(int para);
void delay(int t);
//========================================================
void init()
{
//P1=P3=0Xff;
RES=1;
delay(50);
RES=0;
delay(10);
RES=1;
delay(500);
write_com(0x39); //FUNCTION SET 001,DL,N,DH,IS2,IS1
delay(50);
write_com(0x39); //FUNCTION SET 001,DL,N,DH,IS2,IS1
delay(50);
write_com(0x39); //FUNCTION SET 001,DL,N,DH,IS2,IS1
delay(50);
write_com(0x15); //INTERNAL FREQ 0001B10Fx B:Bias ; Fx: Frame frequency
delay(50);
write_com(0x7f); //CONTRAST SET 0111CCCC ,C3,C2,C1,C0
delay(50);
write_com(0x5e); //POWER/ICON/CONTRAST CTRL 0101IBCC
delay(50);
write_com(0x6c); //Follower Control 0110FRRR , F=1,Follower on; 0:off; RRR: Ra/Rb
delay(50);
write_com(0x01); //CLR DISPLAY
delay(500);
write_com(0x0c); //DISPLAY ON ,00001DCB ,D=1:Display on; 0:off
delay(50);
}
//========================================================
void font1()
{
int i,j,k;
write_com(0x80); //
delay(50);
for(i=0;i<16;i++)
{
write_data(0X30);
}
write_com(0x90);
delay(50);
for(j=0;j<16;j++)
{
write_data(0X31);
}
write_com(0xa0);
delay(50);
for(k=0;k<16;k++)
{
write_data(0X32);
}
}
//========================================================
void font2()
{
int i,j,k;
write_com(0x80); //
delay(50);
for(i=0;i<16;i++)
{
write_data(0X33);
}
write_com(0x90);
delay(50);
for(j=0;j<16;j++)
{
write_data(0X34);
}
write_com(0xa0);
delay(50);
for(k=0;k<16;k++)
{
write_data(0X35);
}
}
//========================================================
void font3()
{
int i,j,k;
write_com(0x80); //
delay(50);
for(i=0;i<16;i++)
{
write_data(0X36);
}
write_com(0x90);
delay(50);
for(j=0;j<16;j++)
{
write_data(0X37);
}
write_com(0xa0);
delay(50);
for(k=0;k<16;k++)
{
write_data(0X38);
}
}
//========================================================
void d_icon()
{
//int i;
write_com(0x39);
delay(50);
write_com(0x5e);
delay(50);
write_com(0x40); //
delay(50);
//*
write_data(0x15);
write_com(0x41); //
delay(50);
write_data(0x01);
write_com(0x42); //
delay(50);
write_data(0x14);
write_com(0x43); //
delay(50);
write_data(0x01);
write_com(0x44); //
delay(50);
write_data(0x09);
write_com(0x45); //
delay(50);
write_data(0x00);
write_com(0x46); //
delay(50);
write_data(0x05);
write_com(0x47); //
delay(50);
write_data(0x08);
write_com(0x48); //
delay(50);
write_data(0x10);
write_com(0x49); //
delay(50);
write_data(0x10);
write_com(0x4a); //
delay(50);
write_data(0x08);
write_com(0x4b); //
delay(50);
write_data(0x0a);
write_com(0x4c); //
delay(50);
write_data(0x01);
write_com(0x4d); //
delay(50);
write_data(0x00);
write_com(0x4e); //
delay(50);
write_data(0x01);
write_com(0x4f); //
delay(50);
write_data(0x00);
//*/
//for(i=0;i<16;i++)
//{
// write_data(0x1f);
// }
}
//========================================================
void c_icon()
{
int i;
write_com(0x39);
delay(50);
write_com(0x5e);
delay(50);
write_com(0x40); //
delay(50);
for(i=0;i<16;i++)
{
write_data(0xff);
}
}
//========================================================
void write_com(int para)
{
int j;
j=8;
CS1=0;
A0=0;
do
{
if(para&0x80)
SDI=1;
else
SDI=0;
SCL=0;
SCL=1;
--j;
para<<=1;
}
while(j);
CS1=1;
}
//========================================================
void write_data(int para)
{
int j;
j=8;
CS1=0;
A0=1;
do
{
if(para&0x80)
SDI=1;
else
SDI=0;
SCL=0;
SCL=1;
--j;
para<<=1;
}
while(j);
CS1=1;
}
//========================================================
void kscan()
{
delay(50);
while(key1==1)
{
delay(50);
}
}
//========================================================
void write_cgram()
{
int i;
write_com(0x38);
delay(50);
write_com(0x40);
delay(50);
for(i=0;i<8;i++)
{
write_data(0x1f);
}
for(i=8;i<16;i++)
{
write_data(0x55);
}
for(i=16;i<17;i++)
{
write_data(0x55);
write_data(0xaa);
write_data(0x55);
write_data(0xaa);
write_data(0x55);
write_data(0xaa);
write_data(0x55);
write_data(0xaa);
}
for(i=24;i<25;i++)
{
//write_data(0x1f);
write_data(0x00);
write_data(0x1f);
write_data(0x00);
write_data(0x1f);
write_data(0x00);
write_data(0x1f);
write_data(0x00);
write_data(0x1f);
}
}
//========================================================
void d_cgram(int p)
{
int i,j;
write_com(0x80);
delay(50);
for(i=0;i<20;i++)
{
write_data(p);
}
write_com(0x90);
delay(50);
for(j=0;j<20;j++)
{
write_data(p);
}
write_com(0xa0);
delay(50);
for(j=0;j<20;j++)
{
write_data(p);
}
}
//========================================================
void delay(int t)
{
register int i,j;
for(i=0;i<t;i++)
for(j=0;j<125;j++);
}
//========================================================
main()
{
init();
delay(200);
//kscan();
c_icon();
while(1)
{
font1();
delay(200);
kscan();
font2();
delay(200);
kscan();
font3();
delay(200);
kscan();
write_com(0x01);
delay(500);
write_cgram();
d_cgram(0);
delay(200);
kscan();
write_com(0x01);
delay(500);
write_cgram();
d_cgram(1);
delay(200);
kscan();
write_com(0x01);
delay(500);
write_cgram();
d_cgram(2);
delay(200);
kscan();
write_com(0x01);
delay(500);
write_cgram();
d_cgram(3);
delay(200);
kscan();
}
}
加载中...
一周热门
更多
>
相关问题
【东软载波ESF0654 PDS开发板活动】开箱
1 个回答
东软载波ESF0654 PDS开发板外部中断
1 个回答
东软载波ESF0654 PDS开发板高级控制定时器AD16C4T
1 个回答
用串口调试助手为什么只能在hex模式接收发送而在文本模式不行
9 个回答
触摸芯片SC02B/SC04B在地砖灯的设计方案
1 个回答
东软载波ESF0654 PDS开发板串口USART0代码分享
1 个回答
普通32位单片机使用linux的应用代码
5 个回答
东软载波ESF0654 PDS开发板AT24C04的调试
9 个回答
相关文章
51单片机与蓝牙模块连接
0个评论
51单片机的硬件结构
0个评论
基于51单片机的无线遥控器制作
0个评论
51单片机 AD转换
0个评论
51单片机数码管递增显示
0个评论
如何实现对单片机寄存器的访问
0个评论
基于51单片机的指纹密码锁
0个评论
×
关闭
采纳回答
向帮助了您的网友说句感谢的话吧!
非常感谢!
确 认
×
关闭
编辑标签
最多设置5个标签!
51单片机
保存
关闭
×
关闭
举报内容
检举类型
检举内容
检举用户
检举原因
广告推广
恶意灌水
回答内容与提问无关
抄袭答案
其他
检举说明(必填)
提交
关闭
×
关闭
您已邀请
15
人回答
查看邀请
擅长该话题的人
回答过该话题的人
我关注的人
/********************************************************;
;* IC : ST7036 *;
;* MCU type : W78E52B(8K ROM) *;
;* Data : 4Line mode *;
;********************************************************/
#include<reg51.h>
#include<intrins.h>
#define uint unsigned int
#define uchar unsigned char
//========================================================
sbit RES=P3^1;
sbit CS1=P3^3;
sbit A0=P3^0;
sbit SCL=P1^0;
sbit SDI=P1^1;
sbit key1=P3^4;
//========================================================
void init(); //初始化
void font1(); //字形1
void font2(); //字形2
void font3(); //字形3
void d_icon();
void c_icon();
void write_cgram();
void d_cgram(int p);
void write_com(int para);
void write_data(int para);
void delay(int t);
//========================================================
void init()
{
//P1=P3=0Xff;
RES=1;
delay(50);
RES=0;
delay(10);
RES=1;
delay(500);
write_com(0x39); //FUNCTION SET 001,DL,N,DH,IS2,IS1
delay(50);
write_com(0x39); //FUNCTION SET 001,DL,N,DH,IS2,IS1
delay(50);
write_com(0x39); //FUNCTION SET 001,DL,N,DH,IS2,IS1
delay(50);
write_com(0x15); //INTERNAL FREQ 0001B10Fx B:Bias ; Fx: Frame frequency
delay(50);
write_com(0x7f); //CONTRAST SET 0111CCCC ,C3,C2,C1,C0
delay(50);
write_com(0x5e); //POWER/ICON/CONTRAST CTRL 0101IBCC
delay(50);
write_com(0x6c); //Follower Control 0110FRRR , F=1,Follower on; 0:off; RRR: Ra/Rb
delay(50);
write_com(0x01); //CLR DISPLAY
delay(500);
write_com(0x0c); //DISPLAY ON ,00001DCB ,D=1:Display on; 0:off
delay(50);
}
//========================================================
void font1()
{
int i,j,k;
write_com(0x80); //
delay(50);
for(i=0;i<16;i++)
{
write_data(0X30);
}
write_com(0x90);
delay(50);
for(j=0;j<16;j++)
{
write_data(0X31);
}
write_com(0xa0);
delay(50);
for(k=0;k<16;k++)
{
write_data(0X32);
}
}
//========================================================
void font2()
{
int i,j,k;
write_com(0x80); //
delay(50);
for(i=0;i<16;i++)
{
write_data(0X33);
}
write_com(0x90);
delay(50);
for(j=0;j<16;j++)
{
write_data(0X34);
}
write_com(0xa0);
delay(50);
for(k=0;k<16;k++)
{
write_data(0X35);
}
}
//========================================================
void font3()
{
int i,j,k;
write_com(0x80); //
delay(50);
for(i=0;i<16;i++)
{
write_data(0X36);
}
write_com(0x90);
delay(50);
for(j=0;j<16;j++)
{
write_data(0X37);
}
write_com(0xa0);
delay(50);
for(k=0;k<16;k++)
{
write_data(0X38);
}
}
//========================================================
void d_icon()
{
//int i;
write_com(0x39);
delay(50);
write_com(0x5e);
delay(50);
write_com(0x40); //
delay(50);
//*
write_data(0x15);
write_com(0x41); //
delay(50);
write_data(0x01);
write_com(0x42); //
delay(50);
write_data(0x14);
write_com(0x43); //
delay(50);
write_data(0x01);
write_com(0x44); //
delay(50);
write_data(0x09);
write_com(0x45); //
delay(50);
write_data(0x00);
write_com(0x46); //
delay(50);
write_data(0x05);
write_com(0x47); //
delay(50);
write_data(0x08);
write_com(0x48); //
delay(50);
write_data(0x10);
write_com(0x49); //
delay(50);
write_data(0x10);
write_com(0x4a); //
delay(50);
write_data(0x08);
write_com(0x4b); //
delay(50);
write_data(0x0a);
write_com(0x4c); //
delay(50);
write_data(0x01);
write_com(0x4d); //
delay(50);
write_data(0x00);
write_com(0x4e); //
delay(50);
write_data(0x01);
write_com(0x4f); //
delay(50);
write_data(0x00);
//*/
//for(i=0;i<16;i++)
//{
// write_data(0x1f);
// }
}
//========================================================
void c_icon()
{
int i;
write_com(0x39);
delay(50);
write_com(0x5e);
delay(50);
write_com(0x40); //
delay(50);
for(i=0;i<16;i++)
{
write_data(0xff);
}
}
//========================================================
void write_com(int para)
{
int j;
j=8;
CS1=0;
A0=0;
do
{
if(para&0x80)
SDI=1;
else
SDI=0;
SCL=0;
SCL=1;
--j;
para<<=1;
}
while(j);
CS1=1;
}
//========================================================
void write_data(int para)
{
int j;
j=8;
CS1=0;
A0=1;
do
{
if(para&0x80)
SDI=1;
else
SDI=0;
SCL=0;
SCL=1;
--j;
para<<=1;
}
while(j);
CS1=1;
}
//========================================================
void kscan()
{
delay(50);
while(key1==1)
{
delay(50);
}
}
//========================================================
void write_cgram()
{
int i;
write_com(0x38);
delay(50);
write_com(0x40);
delay(50);
for(i=0;i<8;i++)
{
write_data(0x1f);
}
for(i=8;i<16;i++)
{
write_data(0x55);
}
for(i=16;i<17;i++)
{
write_data(0x55);
write_data(0xaa);
write_data(0x55);
write_data(0xaa);
write_data(0x55);
write_data(0xaa);
write_data(0x55);
write_data(0xaa);
}
for(i=24;i<25;i++)
{
//write_data(0x1f);
write_data(0x00);
write_data(0x1f);
write_data(0x00);
write_data(0x1f);
write_data(0x00);
write_data(0x1f);
write_data(0x00);
write_data(0x1f);
}
}
//========================================================
void d_cgram(int p)
{
int i,j;
write_com(0x80);
delay(50);
for(i=0;i<20;i++)
{
write_data(p);
}
write_com(0x90);
delay(50);
for(j=0;j<20;j++)
{
write_data(p);
}
write_com(0xa0);
delay(50);
for(j=0;j<20;j++)
{
write_data(p);
}
}
//========================================================
void delay(int t)
{
register int i,j;
for(i=0;i<t;i++)
for(j=0;j<125;j++);
}
//========================================================
main()
{
init();
delay(200);
//kscan();
c_icon();
while(1)
{
font1();
delay(200);
kscan();
font2();
delay(200);
kscan();
font3();
delay(200);
kscan();
write_com(0x01);
delay(500);
write_cgram();
d_cgram(0);
delay(200);
kscan();
write_com(0x01);
delay(500);
write_cgram();
d_cgram(1);
delay(200);
kscan();
write_com(0x01);
delay(500);
write_cgram();
d_cgram(2);
delay(200);
kscan();
write_com(0x01);
delay(500);
write_cgram();
d_cgram(3);
delay(200);
kscan();
}
}
一周热门 更多>