Sie sind auf Seite 1von 7

//

19264 Demo Program


//***************************************************************************
//: CPU=89C52
*
//RS=P3.0
R/W=P3.1
E=P3.2
CS1=P3.3
CS2=P3.4
CS3=P3.5
*
//SysClock=12MHz
DB0-DB7=P1.0-P1.7
//SysClock=12MHz
DB0-DB7=P1.0-P1.7
//Reset 1
//V0 -6v
-6v 
//vee 5~ -13v
//leda +5v
//vss 0v
//vdd 5v
//P1 
//***************************************************************************
#include
#include
#include
#include

"STC89C51RC_RD_PLUS.H"
<stdlib.h>
<intrins.h>
<stdio.h>

#include "code_data.h"
/****************************************/
sbit
sbit
sbit
sbit
sbit
sbit
sbit
sbit

RS =P2^0;
RW =P2^1;
E =P2^5;
CSL =P2^2;
CSM =P2^3;
CSR =P2^4;
CPUWR =P3^6;
CPURD =P3^7;

unsigned char Page;


unsigned char Col;

//
//
//
//
//
//

//
//

void Delay(unsigned int MS);


void wtcom(void);
/***************************/
/*Busy
*/
/***************************/
void BusyL(void)
{
CSL= 0;
CSM= 1;
CSR= 1;
wtcom();
}
void BusyM(void)
{
CSL= 1;
CSM= 0;
CSR= 1;
wtcom();
}

// 

void BusyR(void)
{
CSL= 1;
CSM= 1;
CSR= 0;
wtcom();
}
void wtcom(void)
{
RS = 0;
//
RW = 1;
P0 = 0xFF;
//0xff
E = 1;
_nop_();_nop_();_nop_();
while(P0 & 0x80);
//Status Read Bit7 = BUSY
E = 0;
_nop_();_nop_();_nop_();
}
/********************************************************/
/*LCM
*/
/********************************************************/
void Locatexy(void)
{
unsigned char x,y;
switch (Col&0xc0)
/* col.and.0xC0
*/
{
/*
*/
case 0: {BusyL();break;}/* */
case 0x40:
{BusyM();break;}/* */
case 0x80:
{BusyR();break;}/* */
}
x = Col&0x3F|0x40;
/* col.and.0x3f.or.Set Y Address*/
y = Page&0x07|0xB8;
/* row.and.0x07.or.set Page
*/
wtcom();
/* waitting for enable */
RS = 0;
//
RW = 0;
//
P0 = y;
//
E = 1;
_nop_();_nop_();_nop_();_nop_();_nop_();
E = 0;
_nop_();_nop_();_nop_();_nop_();_nop_();
wtcom();
/* waitting for enable */
RS = 0;
RW = 0;
P0 = x;
//
E = 1;
_nop_();_nop_();_nop_();_nop_();_nop_();
E = 0;
_nop_();_nop_();_nop_();_nop_();_nop_();
}
/***************************/
/*
*/
/***************************/
void WriteCommandL( unsigned char CommandByte )
{
BusyL();
P0 = CommandByte;

RS = 0;
//
RW = 0;
E = 1;
_nop_();_nop_();_nop_();_nop_();_nop_();
E = 0;
_nop_();_nop_();_nop_();_nop_();_nop_();
}
void WriteCommandM( unsigned char CommandByte )
{
BusyM();
P0 = CommandByte;
RS = 0;
//
RW = 0;
E = 1;
_nop_();_nop_();_nop_();_nop_();_nop_();
E = 0;
_nop_();_nop_();_nop_();_nop_();_nop_();
}
void WriteCommandR( unsigned char CommandByte )
{
BusyR();
P0 = CommandByte;
RS = 0;
//
RW = 0;
E = 1;
_nop_();_nop_();_nop_();_nop_();_nop_();
E = 0;
_nop_();_nop_();_nop_();_nop_();_nop_();
}
/***************************/
/*
*/
/***************************/
unsigned char ReadData( void )
{
unsigned char DataByte;
Locatexy();
/*
RS = 1;
/**/
RW = 1;
/* */
P0 = 0xFF;
//0xff
E = 1;
/*LCM*/
_nop_();_nop_();_nop_();_nop_();_nop_();
DataByte = P0; /*P1 */
E = 0;
_nop_();_nop_();_nop_();_nop_();_nop_();
return DataByte;
}
/***************************/
/*
*/
/***************************/
void WriteData( unsigned char DataByte )
{
Locatexy();
/*
RS = 1;
/**/
RW = 0;
/* */
P0 = DataByte; /* */
E = 1;
/*LCM*/

*/

*/

_nop_();_nop_();_nop_();_nop_();_nop_();
E = 0;
_nop_();_nop_();_nop_();_nop_();_nop_();
}
void LcmClear( void )
{
Page = 0;
Col = 0;
for(Page=0;Page<8;Page++)
for(Col=0;Col<192;Col++)
WriteData(0);
}
void LcmInit( void )
{
WriteCommandL(0x3f);
WriteCommandM(0x3f);
WriteCommandR(0x3f);

//

WriteCommandL(0xc0);
WriteCommandM(0xc0);
WriteCommandR(0xc0);

//=0

WriteCommandL(0x3f);
WriteCommandM(0x3f);
WriteCommandR(0x3f);

//

LcmClear();
Col = 0;
Page= 0;
Locatexy();
}
///////////////////////////////////////////////////////////////////////////
void LcmPutDots( unsigned char DotByte )//
{
Page = 0;
Col = 0;
for(Page=0;Page<8;Page++)
{
for(Col=0;Col<192;Col++)
{
WriteData( DotByte );
DotByte = ~DotByte;
}
}
}
void LcmPutBMP( unsigned char *puts ) //
{
unsigned int X=0;
Page = 0;
Col = 0;
for(Page=0;Page<8;Page++)
{
for(Col=0;Col<192;Col++)
{
WriteData( puts[X] );
X++;
}

}
}
void LcmReverseBMP( void ) //
{
unsigned char temp;
Page = 0;
Col = 0;
for(Page=0;Page<8;Page++)
{
for(Col=0;Col<192;Col++)
{
temp = ReadData();
temp = ReadData();
temp = ~temp;
WriteData(temp);
}
}
}

//

void Delay(unsigned int MS)


{
unsigned char us,usn;
while(MS!=0)
{
usn = 2;
//for 12M
while(usn!=0)
{
us=0xf6;
while (us!=0){us--;};
usn--;
}
MS--;
}
}
/****************************************/
/*
27
*/
/****************************************/
void write_chars(unsigned char x,unsigned char y,unsigned char code *date,unsign
ed char quantity)//
{
unsigned char i,ii,iii;
Page = 0;
Col = 0;
for(i=0;i<quantity;i++) //
{
for(ii=0;ii<2;ii++) //
{
Page=x+ii;
for(iii=0;iii<7;iii++) //
{
Col=iii+7*(i+y);
WriteData(date[iii+7*ii+14*i]);
}
}
}
}
/****************************************/
/* 12 */

/****************************************/
void write_chineses(unsigned char x,unsigned char y,unsigned char code *date,uns
igned char quantity)//
{
unsigned char i,ii,iii;
Page = 0;
Col = 0;
for(i=0;i<quantity;i++)
{
for(ii=0;ii<2;ii++) //
{
Page=x+ii;
for(iii=0;iii<15;iii++)
{
Col=iii+15*(i+y);
WriteData(date[iii+15*ii+30*i]);
}
}
}
}
/*********************************************/
/*
*/
void write_Reverse_chineses(unsigned char x,unsigned char y,unsigned char quanti
ty)//
{
unsigned char temp;
unsigned char i,ii,iii;
Page = 0;
Col = 0;
for(i=0;i<quantity;i++)
{
for(ii=0;ii<2;ii++) //
{
Page=x+ii;
for(iii=0;iii<15;iii++)
{
Col=iii+15*(i+y);
temp = ReadData();
//
temp = ReadData();
temp = ~temp;
WriteData(temp);
}
}
}
}
///////////////////////////////////////////
void Main( )
{
unsigned char kp=10;
CPUWR=1;
CPURD=0;
Delay(200);
//
LcmInit();
LcmClear();
CPUWR=1;
CPURD=0;
while(1)
{

P4=P4&0xfd;
LcmClear();
while(kp--)
{
write_chineses(3,2,pray,8);
Delay(100);
write_Reverse_chineses(3,2,8);
Delay(100);
}
LcmClear();
write_chars(2,4,moble_num,13);
write_chars(4,4,QQ,16);
kp=10;
while(kp--)
{
write_chineses(0,0,moble,3);
Delay(100);
write_Reverse_chineses(0,0,3);
Delay(100);
}
Delay(10000);
LcmClear();//
write_chineses(4,2,write_me,5);
Delay(500);
LcmReverseBMP();
Delay(500);
LcmReverseBMP();
Delay(500);
LcmReverseBMP();
Delay(500);
LcmReverseBMP();
Delay(1500);
LcmReverseBMP();
LcmPutBMP(BMP1);
Delay(1500);
LcmReverseBMP();
Delay(1500);
LcmPutBMP(BMP2);
Delay(1500);
LcmReverseBMP();
Delay(1500);
for(kp=0;kp<=255;kp++){
LcmPutDots(kp);
Delay(2500);
}
}
}

Das könnte Ihnen auch gefallen