/*
****************************************************************************************
* 数据类型
*
****************************************************************************************
*/
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 */
//===============================
//Da
//===============================
typedef union {
unsigned char UByte[2];
unsigned int UInt;
} UWORD;
void SSD1963Da
void SSD1963Da
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(默认情况下为8080),可以通过修改Conf 跳点来修改读写方式。
******************************************************/
void SSD1963Command_8(uchar cmd);
void SSD1963Da
void SSD1963Init();
uchar GetSSD1963Da
uint GetSSD1963Da
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 是一个结构体
//注意在给1963写命令时,只能用数据线的低8位来传输数据。
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 SSD1963Da
{
UWORD temp;
temp.UInt=dat;
SetSSD1963DC();
SetSSD1963RD();
ClrSSD1963CS();
ClrSSD1963WR();
DataPortL=temp.UByte[1];
DataPortH=temp.UByte[0];
SetSSD1963WR();
SetSSD1963CS();
}
void SSD1963Da
{
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 SSD1963Da
{
SetSSD1963DC();
SetSSD1963RD();
ClrSSD1963CS();
ClrSSD1963WR();
DataPortL=sdata;
DataPortH=0X00;
SetSSD1963WR();
SetSSD1963CS();
}
/*void SSD1963Da
{
SetSSD1963DC();
SetSSD1963RD();
ClrSSD1963WR();
ClrSSD1963CS();
DataPortL=sdataL;
DataPortH=sdataH;
nop();nop();nop(); nop();nop();nop();
SetSSD1963WR();
SetSSD1963CS();
}*/
uchar GetSSD1963Da
{
uchar sdata;
ClrSSD1963RD();
SetSSD1963WR();
SetSSD1963DC();
ClrSSD1963CS();
sdata=DataPortL;
nop();nop();nop();nop();nop();nop();
SetSSD1963RD();
SetSSD1963CS();
return sdata;
}
uint GetSSD1963Da
{
uint sdata;
unsigned char SFRPAGE_save = SFRPAGE; // Save the current SFRPAGE
SFRPAGE = CONFIG_PAGE; //设置输入输出
P1MDOUT=0x00; ///输出设置为 高阻
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;//设置为 上拉 输出 。
P2MDOUT=0xff;
SFRPAGE = SFRPAGE_save; // Restore the SFRPAGE
return sdata;
}
uint GetPixel(uint Col,uint Page)
{
uint temp;
uint color;
SSD1963Command_8(0x2a); //设置行开始和结束的位置
SSD1963Da
SSD1963Da
temp=Col;
SSD1963Da
SSD1963Da
SSD1963Command_8(0x2b);
SSD1963Da
SSD1963Da
temp=Page;
SSD1963Da
SSD1963Da
SSD1963Command_8(0x2E);
color=GetSSD1963Da
return color;
}
void SetPixel(uint Col,uint Page,uint color)
{
uint temp;
SSD1963Command_8(0x2a); //设置行开始和结束的位置
temp=Col;
SSD1963Da
SSD1963Da
temp=Col;
SSD1963Da
SSD1963Da
SSD1963Command_8(0x2b);
temp=Page;
SSD1963Da
SSD1963Da
temp=Page;
SSD1963Da
SSD1963Da
SSD1963Command_8(0x2c);
// for(i=0;i<9;i++)
// {
SSD1963Da
// }
}
//初始化程序
void SSD1963Init()
{
//software reset
SSD1963Command_8(0x01);
Delay_Ms(400);
SSD1963Command_8(0x01);
Delay_Ms(400);
//enable pll
SSD1963Command_8(0xe0);
Delay_Ms(400);
SSD1963Da
Delay_Ms(400);
SSD1963Command_8(0xe0);
Delay_Ms(400);
SSD1963Da
Delay_Ms(400);
//pll: n= 34 m= 3
SSD1963Command_8(0xe2);
SSD1963Da
SSD1963Da
SSD1963Da
//dotclk setting
SSD1963Command_8(0xe6);
SSD1963Da
SSD1963Da
SSD1963Da
//panel setting
SSD1963Command_8(0xb0);
Delay_Us(100);
SSD1963Da
SSD1963Da
SSD1963Da
SSD1963Da
SSD1963Da
SSD1963Da
SSD1963Da
//pixel format
SSD1963Command_8(0x3a);
SSD1963Da
//hsync setting
SSD1963Command_8(0xb4);
SSD1963Da
SSD1963Da
SSD1963Da
SSD1963Da
SSD1963Da
SSD1963Da
SSD1963Da
SSD1963Da
//vsync setting
SSD1963Command_8(0xb6);
SSD1963Da
SSD1963Da
SSD1963Da
SSD1963Da
SSD1963Da
SSD1963Da
SSD1963Da
//col start_end
SSD1963Command_8(0x2a);
SSD1963Da
SSD1963Da
SSD1963Da
SSD1963Da
//row start_end
SSD1963Command_8(0x2b);
SSD1963Da
SSD1963Da
SSD1963Da
SSD1963Da
SSD1963Command_8(0x36);
SSD1963Da
//MCU IF setting
//SSD1963Command_8(13);
SSD1963Command_8(0xf0);
SSD1963Da
//SSD1963Command_8(0x35);
//display on
SSD1963Command_8(0x29);
SSD1963Command_8(0xbe);//设置PWM
SSD1963Da
SSD1963Da
SSD1963Da
SSD1963Da
SSD1963Da
SSD1963Da
SSD1963Command_8(0xD4);//(Define the threshold value)
SSD1963Da
SSD1963Da
SSD1963Da
SSD1963Da
SSD1963Da
SSD1963Da
SSD1963Da
SSD1963Da
SSD1963Da
SSD1963Command_8(0xd0);
SSD1963Da
// ReadSSD1963Set();
}
上一篇:AT89C2051+AD7545正弦信号发生器
下一篇:在Keil C51函数中加入ASM代码
推荐阅读最新更新时间:2024-03-16 15:04