微波EDA网,见证研发工程师的成长!
首页 > 研发问答 > 嵌入式设计讨论 > MCU和单片机设计讨论 > 最近在看12864,可是他一直不亮啊

最近在看12864,可是他一直不亮啊

时间:10-02 整理:3721RD 点击:
我用的是普中的开发板(某宝买的),12864B是在别处买的,说是有字库。但是我现在插在板子上之后只有背景亮度,并没有显示文字。我看板子上的端口是P10,但是我在程序里写P10的时候会报错。

你的程序是对应普通的不带字库的12864,至于能不能点亮还是得连接了屏才知道,建议要注意对比度得调整,应该是要接一个可调电阻得,另外测试时可以用清屏和全屏显示看效果

要看你手上的12864的手册,带字库的12864的接口可能跟不带字库的接口不一样,初接触12864最后选不带字库的显示屏

那这个是不是就可以点亮屏了?
#include <reg51.h>

#define uchar unsigned char
#define LCMdata P0
#define Busy 0x80
sbit RS=P1^1;
sbit RW=P3^6;
sbit E=P3^7;
sbit REST=P2^7;

void Display_String (uchar line,uchar *string);
void Wr_Data (uchar wrdata);

void Wr_Command (uchar wrcommand ,busyc);
void RDbf(void);
void Lcm_Init(void);
void Delay5Ms(void);

uchar code string_1[]={"Have Fun"} ;
void main(void)
{       
        Lcm_Init();
        Display_String(1,string_1);
        while(1);
        }
void Display_String(uchar line, uchar *string)
{
        uchar addr,i;
        if (line==1)
                addr=0x80;
        Wr_Command(addr,1);
        for (i=0;i<16;i++)
        {
                Wr_Data(*string++);
        }
}
void Wr_Data(uchar wrdata)
{
        RDbf();
        RS=1;
        RW=0;
        E=1;
        LCMdata=wrdata;
        E=0;
}
void Wr_Command(uchar wrcommand,busyc)
{
        if (busyc)
                RDbf();
        RS=0;
        RW=0;
        E=1;
        LCMdata=wrcommand;
        E=0;
}
void RDbf(void)
{
        while(1)
        {
        RS=0;
        RW=1;
        E=0;
        LCMdata=0xFF;
        E=1;
        if ((LCMdata&Busy)==0)
        break;
        }
}
void Lcm_Init(void)
{
        Delay5Ms();
        REST=1;
        REST=0;
        REST=1;
        Wr_Command(0x30,0);
        Delay5Ms();
        Wr_Command(0x30,0);
        Delau5Ms();
        Wr_Command(0x0C,1);
        Delau5Ms();
        Wr_Command(0x01,1);
        Delau5Ms();
       
        Delau5Ms();
        Wr_Command(0x06,1);
        Delau5Ms();
}
void Delay5Ms(void)
{
        unsigned int TempCyc=5552;
        while (TempCyc--);
}

                                         

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

网站地图

Top