新聞中心

SSD1963示例程序

作者: 時間:2016-11-11 來源:網(wǎng)絡(luò) 收藏
本程序是C8051f360 + ssd1963驅(qū)動4.3寸彩屏的初始化程序.,用的是16位數(shù)據(jù)輸入 ,圖片顯示是565RGB格式顯示.

/*

本文引用地址:http://m.butianyuan.cn/article/201611/316729.htm

****************************************************************************************

* 數(shù)據(jù)類型

*

****************************************************************************************

*/

typedef unsigned char uchar; /* Unsigned 8 bit quantity */

typedef signed char schar; /* Signed 8 bit quantity */

typedef unsigned int uint; /* Unsigned 16 bit quantity */

typedef signed int sint; /* Signed 16 bit quantity */

//===============================

//Data type

//===============================

typedef union {

unsigned char UByte[2];

unsigned int UInt;

} UWORD;

void SSD1963Data_16(uchar sdataH,uchar sdataL);

void SSD1963Data1_16(uint dat);

void SSD1963Command_16(uint cmd);

void SetPixel(uint Col,uint Page,uint color); //顯示一個相素點

uint GetPixel(uint Col,uint Page);//得到一個像素點

/******************************************************

SSD1963的Conf腳,用來控制讀寫的方式,

如果為0 則為6800總線MODE

如果位1 ,則為8080總線。

下面的定義是8080 MODE(默認(rèn)情況下為8080),可以通過修改Conf 跳點來修改讀寫方式。

******************************************************/

void SSD1963Command_8(uchar cmd);

void SSD1963Data_8(uchar sdata);

void SSD1963Init();

uchar GetSSD1963Data_8();

uint GetSSD1963Data_16();

void ReadSSD1963Set();

#define SetSSD1963RD() SetBit(P4,4)

#define SetSSD1963WR() SetBit(P4,5)

#define SetSSD1963CS() SetBit(P4,2)

#define SetSSD1963DC() SetBit(P4,3)

#define SetSSD1963Reset() SetBit(P4,1)

#define SetSSD1963Wait() SetBit(p4,0)

#define ClrSSD1963RD() ClrBit(P4,4)

#define ClrSSD1963WR() ClrBit(P4,5)

#define ClrSSD1963CS() ClrBit(P4,2)

#define ClrSSD1963DC() ClrBit(P4,3)

#define ClrSSD1963Reset() ClrBit(P4,1)

#define ClrSSD1963Wait() ClrBit(p4,0)

#define DataPortL P1

#define DataPortH P2

//UWORD 是一個結(jié)構(gòu)體

//注意在給1963寫命令時,只能用數(shù)據(jù)線的低8位來傳輸數(shù)據(jù)。

void SSD1963Command_16(uint cmd)

{

UWORD temp;

temp.UInt=cmd;

ClrSSD1963DC();

SetSSD1963RD();

ClrSSD1963CS();

ClrSSD1963WR();

DataPortL=temp.UByte[1];

DataPortH=temp.UByte[0];

SetSSD1963WR();

SetSSD1963CS();

}

void SSD1963Data1_16(uint dat)

{

UWORD temp;

temp.UInt=dat;

SetSSD1963DC();

SetSSD1963RD();

ClrSSD1963CS();

ClrSSD1963WR();

DataPortL=temp.UByte[1];

DataPortH=temp.UByte[0];

SetSSD1963WR();

SetSSD1963CS();

}

void SSD1963Data_16(uchar sdataH,uchar sdataL)

{

SetSSD1963DC();

SetSSD1963RD();

ClrSSD1963CS();

ClrSSD1963WR();

DataPortL=sdataL;//temp.UByte[1];

DataPortH=sdataH;//temp.UByte[0];

SetSSD1963WR();

SetSSD1963CS();

}

void SSD1963Command_8(uchar cmd)

{

ClrSSD1963DC();

SetSSD1963RD();

ClrSSD1963CS();

ClrSSD1963WR();

DataPortL=cmd;

DataPortH=0X00;

SetSSD1963WR();

SetSSD1963CS();

}

void SSD1963Data_8(uchar sdata)

{

SetSSD1963DC();

SetSSD1963RD();

ClrSSD1963CS();

ClrSSD1963WR();

DataPortL=sdata;

DataPortH=0X00;

SetSSD1963WR();

SetSSD1963CS();

}

/*void SSD1963Data_16(uchar sdataL,uchar sdataH)

{

SetSSD1963DC();

SetSSD1963RD();

ClrSSD1963WR();

ClrSSD1963CS();

DataPortL=sdataL;

DataPortH=sdataH;

nop();nop();nop(); nop();nop();nop();

SetSSD1963WR();

SetSSD1963CS();

}*/

uchar GetSSD1963Data_8()

{

uchar sdata;

ClrSSD1963RD();

SetSSD1963WR();

SetSSD1963DC();

ClrSSD1963CS();

sdata=DataPortL;

nop();nop();nop();nop();nop();nop();

SetSSD1963RD();

SetSSD1963CS();

return sdata;

}

uint GetSSD1963Data_16()

{

uint sdata;

unsigned char SFRPAGE_save = SFRPAGE; // Save the current SFRPAGE

SFRPAGE = CONFIG_PAGE; //設(shè)置輸入輸出

P1MDOUT=0x00; ///輸出設(shè)置為 高阻

P2MDOUT=0x00;

SFRPAGE = SFRPAGE_save; // Restore the SFRPAGE

P1=0xff;

P2=0xff;

ClrSSD1963RD();

SetSSD1963WR();

SetSSD1963DC();

ClrSSD1963CS();

nop();

nop();

sdata=DataPortH;

sdata=sdata<<8;

sdata|=DataPortL;

SetSSD1963RD();

SetSSD1963CS();

SFRPAGE = CONFIG_PAGE;

P1MDOUT=0xff;//設(shè)置為 上拉 輸出 。

P2MDOUT=0xff;

SFRPAGE = SFRPAGE_save; // Restore the SFRPAGE

return sdata;

}

uint GetPixel(uint Col,uint Page)

{

uint temp;

uint color;

SSD1963Command_8(0x2a); //設(shè)置行開始和結(jié)束的位置

SSD1963Data_8(Col/256);

SSD1963Data_8(Col%256);

temp=Col;

SSD1963Data_8(temp/256);

SSD1963Data_8(temp%256);

SSD1963Command_8(0x2b);

SSD1963Data_8(Page/256);

SSD1963Data_8(Page%256);

temp=Page;

SSD1963Data_8(temp/256);

SSD1963Data_8(temp%256);

SSD1963Command_8(0x2E);

color=GetSSD1963Data_16();

return color;

}

void SetPixel(uint Col,uint Page,uint color)

{

uint temp;

SSD1963Command_8(0x2a); //設(shè)置行開始和結(jié)束的位置

temp=Col;

SSD1963Data_8(temp/256);

SSD1963Data_8(temp%256);

temp=Col;

SSD1963Data_8(temp/256);

SSD1963Data_8(temp%256);

SSD1963Command_8(0x2b);

temp=Page;

SSD1963Data_8(temp/256);

SSD1963Data_8(temp%256);

temp=Page;

SSD1963Data_8(temp/256);

SSD1963Data_8(temp%256);

SSD1963Command_8(0x2c);

// for(i=0;i<9;i++)

// {

SSD1963Data1_16(color);

// }

}

//初始化程序

void SSD1963Init()

{

//software reset

SSD1963Command_8(0x01);

Delay_Ms(400);

SSD1963Command_8(0x01);

Delay_Ms(400);

//enable pll

SSD1963Command_8(0xe0);

Delay_Ms(400);

SSD1963Data_8(0x01);

Delay_Ms(400);

SSD1963Command_8(0xe0);

Delay_Ms(400);

SSD1963Data_8(0x03);

Delay_Ms(400);

//pll: n= 34 m= 3

SSD1963Command_8(0xe2);

SSD1963Data_8(0x14);

SSD1963Data_8(0x03);

SSD1963Data_8(0x54);

//dotclk setting

SSD1963Command_8(0xe6);

SSD1963Data_8(0x03);

SSD1963Data_8(0xa0);

SSD1963Data_8(0x00);

//panel setting

SSD1963Command_8(0xb0);

Delay_Us(100);

SSD1963Data_8(0x38);

SSD1963Data_8(0x20);

SSD1963Data_8(0x01);

SSD1963Data_8(0xdf);

SSD1963Data_8(0x01);

SSD1963Data_8(0x0f);

SSD1963Data_8(0x00);

//pixel format

SSD1963Command_8(0x3a);

SSD1963Data_8(0x50);

//hsync setting

SSD1963Command_8(0xb4);

SSD1963Data_8(0x02);

SSD1963Data_8(0x0D);

SSD1963Data_8(0x00);

SSD1963Data_8(0x25);

SSD1963Data_8(0x02);

SSD1963Data_8(0x00);

SSD1963Data_8(0x00);

SSD1963Data_8(0x00);

//vsync setting

SSD1963Command_8(0xb6);

SSD1963Data_8(0x01);

SSD1963Data_8(0x1E);

SSD1963Data_8(0x00);

SSD1963Data_8(0x08);

SSD1963Data_8(0x01);

SSD1963Data_8(0x00);

SSD1963Data_8(0x00);

//col start_end

SSD1963Command_8(0x2a);

SSD1963Data_8(0x00);

SSD1963Data_8(0x00);

SSD1963Data_8(0x01);

SSD1963Data_8(0xdf);//480

//row start_end

SSD1963Command_8(0x2b);

SSD1963Data_8(0x00);

SSD1963Data_8(0x00);

SSD1963Data_8(0x01);

SSD1963Data_8(0x0f);//272

SSD1963Command_8(0x36);

SSD1963Data_8(0x00);

//MCU IF setting

//SSD1963Command_8(13);

SSD1963Command_8(0xf0);

SSD1963Data_8(0x03); //02

//SSD1963Command_8(0x35);

//display on

SSD1963Command_8(0x29);

SSD1963Command_8(0xbe);//設(shè)置PWM

SSD1963Data_8(0X0E);

SSD1963Data_8(0XFF);

SSD1963Data_8(0X09);

SSD1963Data_8(0XFF);

SSD1963Data_8(0X00);

SSD1963Data_8(0X00);

SSD1963Command_8(0xD4);//(Define the threshold value)

SSD1963Data_8(0X00);

SSD1963Data_8(0X09);

SSD1963Data_8(0X90);

SSD1963Data_8(0X00);

SSD1963Data_8(0X17);

SSD1963Data_8(0XE8);

SSD1963Data_8(0X00);

SSD1963Data_8(0X39);

SSD1963Data_8(0X60);

SSD1963Command_8(0xd0);

SSD1963Data_8(0x0d);

// ReadSSD1963Set();

}



關(guān)鍵詞: SSD1963示例程

評論


技術(shù)專區(qū)

關(guān)閉