标题:
单片机12864串行驱动不显示,照着各种资料都调试了还是不行
[打印本页]
作者:
会飞的大象
时间:
2019-4-18 09:16
标题:
单片机12864串行驱动不显示,照着各种资料都调试了还是不行
代码如下:
#ifndef lcd_h
#define lcd_h
#include <reg51.h>
#include <intrins.h>
#define uchar unsigned char
#define uint unsigned int
#define R_D 0xfe //读数据
#define R_C 0xfa //读指令
#define W_D 0xfc //写数据
#define W_C 0xf8 //写指令
sbit CS=P3^4;
sbit SID=P3^3;
sbit SCLK=P3^2;
sbit PSB=P2^7;
sbit RST=P2^6;
void init_LCD();
void Write_LCD(uchar con,uchar date);
//uchar Read_BF(uchar con);
/********************************************
延时毫秒程序
********************************************/
void delay_ms(uint i)
{
uint j;
for(;i>0;i--)
for(j=114;j>0;j--)
;
}
void delay_us(uchar i)
{
for(i;i>0;i--)
_nop_();
}
void Send_Byte(uchar date)
{
uchar i;
//SCLK=0;
for (i=0;i<8;i++)
{
SCLK=0;
if(date&0x80)
SID=1;
else
SID=0;
SCLK=1;
date<<=1;
}
}
uchar Read_Byte()
{
uchar i;
uchar temp,temp1,temp2;
for(i=0;i<8;i++)
{
temp1<<=1;
SCLK=0;
SCLK=1;
SCLK=0;
if(SID)
temp1+=1;
//SCLK=1;
}
for(i=0;i<8;i++)
{
temp2<<=1;
SCLK=0;
SCLK=1;
SCLK=0;
if(SID)
temp2+=1;
//SCLK=1;
}
temp1=0xf0&temp1;
temp2>>=4;
temp=temp1+temp2;
return temp;
}
void CheckBusy()
{
Send_Byte(0xfc);
while(0x80&Read_Byte());
}
void Write_LCD(uchar con,uchar date)
{
uchar date_h,date_l;
date_h=date&0xf0;
date_l=(date&0x0f)<<4;
CS=1;
CheckBusy();
Send_Byte(con);
//delay_us(100);
Send_Byte(date_h);
//delay_us(100);
Send_Byte(date_l);
CS=0;
delay_us(100);
}
void init_LCD()
{
delay_ms(40);
RST=0;
delay_us(100);
RST=1;
PSB=0;
Write_LCD(W_C,0x30);
delay_us(100);
Write_LCD(W_C,0x30);
delay_us(137);
Write_LCD(W_C,0x0c);
delay_us(100);
Write_LCD(W_C,0x01);
delay_ms(10);
Write_LCD(W_C,0x06);
}
#endif
复制代码
main函数
#include <reg51.h>
#include "lcd.h"
//#include "sht11.h"
uchar str[]={"1234567890123456"};
void main()
{
uchar i;
init_LCD();
while(1)
{
Write_LCD(W_C,0x80);
for(i=0;i<16;i++)
{
Write_LCD(W_D,str[i]);
}
}
}
复制代码
照着各种资料都调试了,就是不行,跪求大神指点
作者:
cphnkj188
时间:
2019-5-6 13:15
可能是LCD12864串并设置有误,测量一下PSB电压:5v是并行模式,0v是串行模式,有的屏,是在背面改焊0电阻实现的,仔细看看应该是电路连接问题
欢迎光临 (http://www.51hei.com/bbs/)
Powered by Discuz! X3.1