搜索
bottom↓
回复: 4

我有一张RA8803液晶,是用PIC16F877A来控制的,可就是不能点亮哪位高手帮帮忙啊

[复制链接]

出50入0汤圆

发表于 2008-5-29 18:32:52 | 显示全部楼层 |阅读模式
接线图和程序如下:点击此处下载 ourdev_296594.pdf(文件大小:61K) (原文件名:航信灯接线图 Model (1).pdf)

/*************************************************************
FUNCTIONn:             LCD driver 8080
AUTHOR:                科技
DESCRIPTION:           RA8803
E-mail:               
CREAT DATE:            2006-2-25
MODIFICATION DATE:   
***************************************************************/
#include       <pic.h>;//定义三个头文件

#define RW_WR         RC1
#define E_RD          RC0
#define CS            RC2
#define RS            RC4
#define RST           RC5
#define DATA_BUS      PORTD
#define BUSY           RC3
unsigned char font[]=
{
    0xd2,0xab,0xd3,0xee,0xbf,0xc6,0xbc,0xbc,//耀宇科技
    0xd2,0xab,0xd3,0xee,0xbf,0xc6,0xbc,0xbc//耀宇科技
};
//***************************************以下为函数申明
void Delay(unsigned char shijian);
void Write_Data(unsigned char dat);
void Write_Instruction(unsigned char cmd);
void LCD_Controller_Register(unsigned char dat);
void Misc_Register(unsigned char dat);
void Advance_Power_Setup_Register(unsigned char dat);
void Advance_Display_Setup_Register(unsigned char dat);
void Cursor_Control_Register(unsigned char dat);
void Cursor_Size_Control_Register(unsigned char dat);
void Memory_Access_Mode_Register(unsigned char dat);
void Active_Window(unsigned char x1,unsigned char y1,unsigned char x2,unsigned char y2);
void Display_Window(unsigned char x1,unsigned char y1,unsigned char x2,unsigned char y2);
void Cursor_Position_Register(unsigned char x,unsigned char y);
void Begin_Segment_Position_Register(unsigned char x);
void Shift_Action_Range(unsigned char y1,unsigned char y2);
void Blink_Time_Register(unsigned char dat);
void Frame_Rate_Polarity_Change_At_Common_A_B_Register(unsigned char dat1,unsigned char dat2);
void Shift_Clock_Control_Register(unsigned char  dat);
void Interrupt_Setup_And_Status_Register(unsigned char at);
void Font_Control_Register(unsigned char dat);
void Font_Size_Control_Register(unsigned char dat);
void Display_Chinese(unsigned char fnt[]);
void Initial(void);

/***********************************
** 函数名称: Delay
** 功能描述: 延时时间=(n*9+17)*12/F
** 输 入: n
** 输 出 : 无
** 全局变量:无
** 调用模块: 无
**
** 作 者: 耀宇科技
** 日 期: 2006-2-25
******************************************/
void Delay(unsigned char shijian)
{   unsigned char i;
  for(i=shijian;i!=0;i--)//以10MS为基数的延时函数
{
unsigned int d=1000;//10MS延时函数,1000为10MS,2000为20MS
asm("clrwdt");
while(--d){;}
}
}
/****************************************
** 函数名称: Write_Data
** 功能描述: 传送数据
** 输 入: dat
** 输 出 : 无
** 全局变量:无
** 调用模块: Busy,
**
** 作 者: 耀宇科技
** 日 期: 2006-2-25
******************************************/
#pragma disable
void Write_Data(unsigned char  dat)
{   //while(BUSY);
        DATA_BUS=dat;
    E_RD=1;//置读取位为高,不能读
    RS=1;
        CS=0;
    RW_WR=0;
        Delay(1);
    RW_WR=1;
        CS=1;
        Delay(5);
        return;
}

/******************************************
** 函数名称: Write_Instruction
** 功能描述: 传送命令
** 输 入: dat
** 输 出 : 无
** 全局变量:无
** 调用模块: Busy,
**
** 作 者: 耀宇科技
** 日 期: 2006-2-25
******************************************/
#pragma disable
void Write_Instruction(unsigned char  cmd)
{   // while(BUSY);
        DATA_BUS=cmd;
    E_RD=1;//置读取位为高,不能读
    RS=0;//为低时,存取缓存器,为高时,存取数据
        CS=0;//片选端,为0时选通RA8803,为1时禁止工作
    RW_WR=0;//写入信号,低电位动作,
        Delay(1);
    RW_WR=1;
        CS=1;
        Delay(5);
        return;
}

/***********************************
** 函数名称: LCD_Controller_Register
** 功能描述:
** 输 入: dat
** 输 出 : 无
** 全局变量:无
** 调用模块: Write_Instruction
**
** 作 者: 耀宇科技
** 日 期: 2006-2-25
******************************************/
#pragma disable
void LCD_Controller_Register(unsigned char  dat)
{
    Write_Instruction(0x00);
        Write_Instruction(dat);
        return;
}

/***********************************
** 函数名称: Misc_Register
** 功能描述:
** 输 入: dat
** 输 出 : 无
** 全局变量:无
** 调用模块: Write_Instruction
**
** 作 者: 耀宇科技
** 日 期: 2006-2-25
******************************************/
#pragma disable
void Misc_Register(unsigned char  dat)
{
    Write_Instruction(0x01);
        Write_Instruction(dat);
        return;
}

/***********************************
** 函数名称: Advance_Power_Setup_Register
** 功能描述:
** 输 入: dat
** 输 出 : 无
** 全局变量:无
** 调用模块: Write_Instruction
**
** 作 者: 耀宇科技
** 日 期: 2006-2-25
******************************************/
#pragma disable
void Advance_Power_Setup_Register(unsigned char  dat)
{
    Write_Instruction(0x02);
        Write_Instruction(dat);
        return;
}


/***********************************
** 函数名称: Advance_Display_Setup_Register
** 功能描述:
** 输 入: dat
** 输 出 : 无
** 全局变量:无
** 调用模块: Write_Instruction
**
** 作 者: 耀宇科技
** 日 期: 2006-2-25
******************************************/
#pragma disable
void Advance_Display_Setup_Register(unsigned char  dat)
{
    Write_Instruction(0x03);
        Write_Instruction(dat);
        return;
}

/***********************************
** 函数名称: Cursor_Control_Register
** 功能描述:
** 输 入: dat
** 输 出 : 无
** 全局变量:无
** 调用模块: Write_Instruction
**
** 作 者: 耀宇科技
** 日 期: 2006-2-25
******************************************/
#pragma disable
void Cursor_Control_Register(unsigned char  dat)
{
    Write_Instruction(0x10);
        Write_Instruction(dat);
        return;
}

/***********************************
** 函数名称: Cursor_Size_Control_Register
** 功能描述:
** 输 入: dat
** 输 出 : 无
** 全局变量:无
** 调用模块: Write_Instruction
**
** 作 者: 耀宇科技
** 日 期: 2006-2-25
******************************************/
#pragma disable
void Cursor_Size_Control_Register(unsigned char  dat)
{
    Write_Instruction(0x11);
        Write_Instruction(dat);
        return;
}

/***********************************
** 函数名称: Memory_Access_Mode_Register
** 功能描述:
** 输 入: dat
** 输 出 : 无
** 全局变量:无
** 调用模块: Write_Instruction
**
** 作 者: 耀宇科技
** 日 期: 2006-2-25
******************************************/
#pragma disable
void Memory_Access_Mode_Register(unsigned char  dat)
{
    Write_Instruction(0x12);
        Write_Instruction(dat);
        return;
}

/***********************************
** 函数名称: Active_Window
** 功能描述:
** 输 入: dat
** 输 出 : 无
** 全局变量:无
** 调用模块: Write_Instruction
**
** 作 者: 耀宇科技
** 日 期: 2006-2-25
******************************************/
#pragma disable
void Active_Window(unsigned char  x1,unsigned char  y1,unsigned char  x2,unsigned char  y2)
{
    Write_Instruction(0x40); //Active Window Left Register
        Write_Instruction(x1);
    Write_Instruction(0x20); //Active Window Right Register
        Write_Instruction(x2);
    Write_Instruction(0x50); //Active Window Top Register
        Write_Instruction(y1);
    Write_Instruction(0x30); //Active Window Bottom Register
        Write_Instruction(y2);
        return;
}

/***********************************
** 函数名称: Display_Window
** 功能描述:
** 输 入: dat
** 输 出 : 无
** 全局变量:无
** 调用模块: Write_Instruction
**
** 作 者: 耀宇科技
** 日 期: 2006-2-25
******************************************/
#pragma disable
void Display_Window(unsigned char  x1,unsigned char  y1,unsigned char  x2,unsigned char  y2)
{
    Write_Instruction(0x41); //Display Window Left Register
        Write_Instruction(x1);
    Write_Instruction(0x21); //Display Window Right Register
        Write_Instruction(x2);
    Write_Instruction(0x51); //Display Window Top Register
        Write_Instruction(y1);
    Write_Instruction(0x31); //Display Window Bottom Register
        Write_Instruction(y2);
        return;
}

/***********************************
** 函数名称: Cursor_Position_Register
** 功能描述:
** 输 入: dat
** 输 出 : 无
** 全局变量:无
** 调用模块: Write_Instruction
**
** 作 者: 耀宇科技
** 日 期: 2006-2-25
******************************************/
#pragma disable
void Cursor_Position_Register(unsigned char  x,unsigned char  y)
{
    Write_Instruction(0x60);
        Write_Instruction(x);
    Write_Instruction(0x70);
        Write_Instruction(y);
        return;
}

/***********************************
** 函数名称: Begin_Segment_Position_Register
** 功能描述:
** 输 入: dat
** 输 出 : 无
** 全局变量:无
** 调用模块: Write_Instruction
**
** 作 者: 耀宇科技
** 日 期: 2006-2-25
******************************************/
#pragma disable
void Begin_Segment_Position_Register(unsigned char  x)
{
    Write_Instruction(0x61);
        Write_Instruction(x);
        return;
}


/***********************************
** 函数名称: Shift_Action_Range
** 功能描述:
** 输 入: dat
** 输 出 : 无
** 全局变量:无
** 调用模块: Write_Instruction
**
** 作 者: 耀宇科技
** 日 期: 2006-2-25
******************************************/
#pragma disable
void Shift_Action_Range(unsigned char  y1,unsigned char  y2)
{
    Write_Instruction(0x71);
        Write_Instruction(y1);
    Write_Instruction(0x72);
        Write_Instruction(y2);
        return;
}

/***********************************
** 函数名称: Blink_Time_Register
** 功能描述:
** 输 入: dat
** 输 出 : 无
** 全局变量:无
** 调用模块: Write_Instruction
**
** 作 者: 耀宇科技
** 日 期: 2006-2-25
******************************************/
#pragma disable
void Blink_Time_Register(unsigned char dat)
{
    Write_Instruction(0x80);
        Write_Instruction(dat);
        return;
}

/***********************************
** 函数名称: Frame_Rate_Polarity_Change_At_Common_A_B_Register
** 功能描述:
** 输 入: dat
** 输 出 : 无
** 全局变量:无
** 调用模块: Write_Instruction
**
** 作 者: 耀宇科技
** 日 期: 2006-2-25
******************************************/
#pragma disable
void Frame_Rate_Polarity_Change_At_Common_A_B_Register(unsigned char  dat1,unsigned char  dat2)
{
    Write_Instruction(0x81);
        Write_Instruction(dat1);
    Write_Instruction(0x91);
        Write_Instruction(dat2);
        return;
}


/***********************************
** 函数名称: Shift_Clock_Control_Register
** 功能描述:
** 输 入: dat
** 输 出 : 无
** 全局变量:无
** 调用模块: Write_Instruction
**
** 作 者: 耀宇科技
** 日 期: 2006-2-25
******************************************/
#pragma disable
void Shift_Clock_Control_Register(unsigned char  dat)
{
    Write_Instruction(0x90);
        Write_Instruction(dat);
        return;
}

/***********************************
** 函数名称: Interrupt_Setup_And_Status_Register
** 功能描述:
** 输 入: dat
** 输 出 : 无
** 全局变量:无
** 调用模块: Write_Instruction
**
** 作 者: 耀宇科技
** 日 期: 2006-2-25
******************************************/
#pragma disable
void Interrupt_Setup_And_Status_Register(unsigned char  dat)
{
    Write_Instruction(0xa0);
        Write_Instruction(dat);
        return;
}

/***********************************
** 函数名称: Font_Control_Register(
** 功能描述:
** 输 入: dat
** 输 出 : 无
** 全局变量:无
** 调用模块: Write_Instruction
**
** 作 者: 耀宇科技
** 日 期: 2006-2-25
******************************************/
#pragma disable
void Font_Control_Register(unsigned char  dat)
{
    Write_Instruction(0xf0);
        Write_Instruction(dat);
        return;
}

/***********************************
** 函数名称: Font_Size_Control_Register
** 功能描述:
** 输 入: dat
** 输 出 : 无
** 全局变量:无
** 调用模块: Write_Instruction
**
** 作 者: 耀宇科技
** 日 期: 2006-2-25
******************************************/
#pragma disable
void Font_Size_Control_Register(unsigned char  dat)
{
    Write_Instruction(0xf1);
        Write_Instruction(dat);
        return;
}

/***********************************
** 函数名称: Display_Chinese
** 功能描述: Display_Chinese
** 输 入:  value
** 输 出 : 无
** 全局变量:无
** 调用模块:LCD_Controller_Register,Cursor_Position_Register,Write_Data
**
** 作 者: 耀宇科技
** 日 期: 2006-2-10
******************************************/
#pragma disable
void Display_Chinese(unsigned char fnt[])
{
    register unsigned char i,j;
    LCD_Controller_Register(0xcd);
        Cursor_Position_Register(0x00,0x00);
    for(i=0;i<0x10;i+=2)
        {
                for(j=0;j<0x0f;j++)
                {
            Write_Data(fnt);
                        Write_Data(fnt[i+1]);
                }
        }
    return;
}

#pragma disable
void Initial(void)
{
    TRISD=0X00;//设定数据端口为输出
    TRISC=0X08;//RC3为输入,液晶端口状态忙位检测
    PORTC=0X00;//先输出0清端口状态
    PORTD=0X00;//清零端口
        RST=0;//复位信号置低电平
    Delay(30);//延时1秒
        RST=1;//复位信号置低电平
    Delay(10);//延时2秒
   // while(BUSY);//忙信号检测
    LCD_Controller_Register(0xcd);//缓存器00H正常模式,屏幕开启
        Misc_Register(0xf1);//输出允许,BUSY高电平触发,4MHZ频率
        Advance_Power_Setup_Register(0x10);
        Advance_Display_Setup_Register(0x80);
        Cursor_Control_Register(0x6b);
        Cursor_Size_Control_Register(0x00);
        Memory_Access_Mode_Register(0x91);
        Active_Window(0x00,0x00,0x1d,0x7f);
    Display_Window(0x00,0x00,0x1d,0x7f);
        Begin_Segment_Position_Register(0x0);
        Shift_Action_Range(0x00,0x9f);
        Blink_Time_Register(0xaa);
    Frame_Rate_Polarity_Change_At_Common_A_B_Register(0x00,0x00);
        Shift_Clock_Control_Register(0x10);
        Interrupt_Setup_And_Status_Register(0x11);
        Font_Control_Register(0xa0);
        Font_Size_Control_Register(0x0f);
        Cursor_Position_Register(0x00,0x00);
}

//#pragma disable
//void Step(void) interrupt 0
//{
   // while(IE0==1);
   // return;
//}

main()
{   Initial();
    while(1)
        {
        LCD_Controller_Register(0xcd);
            Delay(600);
            Delay(600);
        Display_Chinese(font);
            Delay(600);
            Delay(600);
    }
}

阿莫论坛20周年了!感谢大家的支持与爱护!!

月入3000的是反美的。收入3万是亲美的。收入30万是移民美国的。收入300万是取得绿卡后回国,教唆那些3000来反美的!

出0入0汤圆

发表于 2008-5-29 18:40:50 | 显示全部楼层
RA8803很容易花屏吧?

出50入0汤圆

 楼主| 发表于 2008-5-29 19:50:59 | 显示全部楼层
我还没有点亮呢,不过我听别人说,在初始里清屏之后是不会花屏的

出0入0汤圆

发表于 2008-5-29 21:21:28 | 显示全部楼层
RA8803不要采用上电复位,最好由单片机来进行复位,RS引脚在不进行读写时置低,这点很不明白,平时置高时死活不显示,置低就没事

出50入0汤圆

 楼主| 发表于 2008-5-30 09:33:02 | 显示全部楼层
RS是数据和缓存选择的控制位,如果平时置低的话,就一直是写缓存的命令
回帖提示: 反政府言论将被立即封锁ID 在按“提交”前,请自问一下:我这样表达会给举报吗,会给自己惹麻烦吗? 另外:尽量不要使用Mark、顶等没有意义的回复。不得大量使用大字体和彩色字。【本论坛不允许直接上传手机拍摄图片,浪费大家下载带宽和论坛服务器空间,请压缩后(图片小于1兆)才上传。压缩方法可以在微信里面发给自己(不要勾选“原图),然后下载,就能得到压缩后的图片】。另外,手机版只能上传图片,要上传附件需要切换到电脑版(不需要使用电脑,手机上切换到电脑版就行,页面底部)。
您需要登录后才可以回帖 登录 | 注册

本版积分规则

手机版|Archiver|amobbs.com 阿莫电子技术论坛 ( 粤ICP备2022115958号, 版权所有:东莞阿莫电子贸易商行 创办于2004年 (公安交互式论坛备案:44190002001997 ) )

GMT+8, 2024-4-27 14:12

© Since 2004 www.amobbs.com, 原www.ourdev.cn, 原www.ouravr.com

快速回复 返回顶部 返回列表