Beruflich Dokumente
Kultur Dokumente
"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;
//
//
//
//
//
//
//
//
//
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 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);
}
}
}