这些小活动你都参加了吗?快来围观一下吧!>>
电子产品世界 » 论坛首页 » 综合技术 » 基础知识 » VXWORKS,NUCLEUS,keil,for,arm,01a,ccd,135

共2条 1/1 1 跳转至

,VXWORKS,NUCLEUS,keil,for,arm,01a,ccd,13581980230, 440驱动夏普LM320192,

院士
2006-09-17 18:14:16     打赏
,VXWORKS,NUCLEUS,keil,for,arm,01a,ccd,13581980230, 440驱动夏普LM320192,



关键词: VXWORKS     NUCLEUS     135819802    

院士
2006-12-22 22:43:00     打赏
2楼
问 已下程序440驱动夏普LM320192,如果设定成单色模式,没问题,设定成4色模式.或16色模式,送显示点,全部是0XFF或0X00,或高字节和低字节一样的数如,0X11,0X22,都没问题,如果全屏幕的数是高字节和低字节相差比较大的数,如0X7A,就是16色模式时单数点全部是7级,双数点全部是10级,就会出现所有点闪烁的现象,那为知道谢谢


extern unsigned char ul_xshcq[38400];              //公有变量显示缓冲区
class Tlcd
{
    public:
          Tlcd(unsigned char *scr_buf);            //构造函数变量初始化
        void InitLCD(unsigned char *scr_buf,unsigned int scr_w,unsigned int scr_h,unsigned int bpp);// 初始化LCD,16级灰度模式
        void LCD_Switch(unsigned int disp_on);    // 打开,关闭LCD屏幕
};
#define SCR_WIDTH        240
#define SCR_HEIGHT        320
#define U32 unsigned int
#define U16 unsigned short
#define S32 int
#define S16 short int
#define U8  unsigned char
#define    S8  char    
// 初始化LCD时所使用的固定参数
#define set_LCD_DISMODE rPDATC |= set_8
#define clr_LCD_DISMODE    rPDATC &= clr_8
#define LCD_DISMODE_dksz rPCONC &= clr_17;rPCONC |= set_16
// LCD屏幕大小
#define LCD_WIDTH        240
#define LCD_HEIGHT        320
// 记录显示缓冲区地址及其宽度
static unsigned scr_buf_addr, scr_width;
#define MVAL_USED    (0)
#define MVAL         (13)
#define INVCLK        (0)
#define INVFRAME        (0)
#define INVLINE        (0)
#define L248         (8)
#define CLKVAL_SL    (12)        // 32Mhz, fr=100Hz (CLKVAL=38.6)
#define M5D(n) ((n) & 0x1fffff)
Tlcd::Tlcd(unsigned char *scr_buf)            //构造函数变量初始化
{
    unsigned long ul_sj;
    ul_sj = 0;
    while(ul_sj<38400)
    {
        *scr_buf = 0x00;              //公有变量显示缓冲区
        ++scr_buf;
        ++ul_sj;
    }           
}
///////////////////////////////////////////////////////////////////////////////
//
//    功能:
//            初始化LCD,必须在调用其他函数之前调用
//    参数:
//            scr_buf            显示缓冲区地址(注意:指定的缓冲区不能跨越4MB边界)
//            scr_w            显示缓冲区宽度(单位:象素)
//            scr_h            显示缓冲区高度(单位:象素)
//            bpp                显示模式(单位:位/象素。1 = 单色,2 = 4级灰度,4 = 16级灰度)
//    返回值:
//            无
//
void Tlcd::InitLCD(unsigned char *scr_buf,unsigned int scr_w,unsigned int scr_h,unsigned int bpp)
{
    rPCOND = 0xaaaaaaaa;                      //port D的配置
    rPUPD = 0x0;                            //上拉电阻配置寄存器
    rPDATD = 0xff;                            //port D的数据寄存器
    rLCDCON1=(2)|(INVFRAME<<2)|(INVLINE<<3)|(INVCLK<<4)|(1<<5)|(MVAL_USED<<7)|(0x3<<8)|(0x3<<10)|(CLKVAL_SL<<12);
    //上升沿装载视频数据,禁止视频输出,LCD FIFO清空;行、帧信号取反;
    //4位单扫描模式;WDLY=8clk,WLH=8clk,CLKVAL_SL=38
    rLCDCON2=(scr_w-1)|(scr_h/4-1<<10)|(10<<21);
    switch(bpp)
    {
        case 1:
        {
            rLCDSADDR1 = 0 << 27 | (unsigned)scr_buf >> 22 << 21 | (unsigned)scr_buf >> 1 & 0x1fffff;
            rLCDSADDR2 = 1<<29|13 << 21 | (unsigned)scr_buf + scr_w * LCD_HEIGHT / 8 >> 1 & 0x1fffff;
             rLCDSADDR3 = (scr_w - LCD_WIDTH) / 16 << 9 | LCD_WIDTH / 16;     
        }
        break;
        case 2:
        {
            rLCDSADDR1 = 1 << 27 | (unsigned)scr_buf >> 22 << 21 | (unsigned)scr_buf >> 1 & 0x1fffff;
            rLCDSADDR2 = 1<<29|13 << 21 | (unsigned)scr_buf + scr_w * LCD_HEIGHT / 4 >> 1 & 0x1fffff;
            rLCDSADDR3 = (scr_w - LCD_WIDTH) / 8 << 9 | LCD_WIDTH / 8;
            rBLUELUT = 0xfa40;
        }
        break;
        case 4:
        {
            rLCDSADDR1 = 2 << 27 | (unsigned)scr_buf >> 22 << 21 | (unsigned)scr_buf >> 1 & 0x1fffff;
            rLCDSADDR2 = 1<<29|13 << 21 | (unsigned)scr_buf + scr_w * LCD_HEIGHT / 2 >> 1 & 0x1fffff;
            rLCDSADDR3 = (scr_w - LCD_WIDTH) / 4 << 9 | LCD_WIDTH / 4;
        }
        break;
        default:
            return;
    }
    if(bpp > 1)                    // 如果以灰度模式显示,则需配置调色板
    {
        rDITHMODE = 0x12210;
        rDP1_2 = 0xa5a5;
        rDP4_7 = 0xba5da65;
        rDP3_5 = 0xa5a5f;
        rDP2_3 = 0xd6b;
        rDP5_7 = 0xeb7b5ed;
        rDP3_4 = 0x7dbe;
        rDP4_5 = 0x7ebdf;
        rDP6_7 = 0x7fdfbfe;
    }
    rLCDCON1=(3)|(INVFRAME<<2)|(INVLINE<<3)|(INVCLK<<4)|(1<<5)|(MVAL_USED<<7)|(0x3<<8)|(0x3<<10)|(CLKVAL_SL<<12);
        //上升沿装载视频数据,允许视频输出,LCD FIFO清空;行、帧信号取反;
        //4位单扫描模式;WDLY=8clk,WLH=8clk,CLKVAL_SL=38
}

///////////////////////////////////////////////////////////////////////////////
//
//    功能:
//            指定LCD屏幕显示状态
//    参数:
//            disp_on            显示状态(1 = 开,2 = 关)
//    返回值:
//            无
//
void Tlcd::LCD_Switch(unsigned int disp_on)
{
    LCD_DISMODE_dksz;
    if(disp_on == 0)
    {
        //set_LCD_DISMODE;
        clr_LCD_DISMODE;    
    }
    else
    {
        //clr_LCD_DISMODE;
        set_LCD_DISMODE;
    }
} 1: 就象电视无信号时的燥声点一样 2: 是不是干扰的问题

共2条 1/1 1 跳转至

回复

匿名不能发帖!请先 [ 登陆 注册 ]