//M68 8bit-4bit interface
#include <AT89X51.H>
#define STB P2_1
#define SCLK P2_4
#define SDATA P2_0
unsigned char bdata data_byte;
sbit bit7=data_byte^7;
sbit bit6=data_byte^6;
sbit bit5=data_byte^5;
sbit bit4=data_byte^4;
sbit bit3=data_byte^3;
sbit bit2=data_byte^2;
sbit bit1=data_byte^1;
sbit bit0=data_byte^0;
unsigned char i,j,k;
unsigned char code UDF[13][8]=
{
0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0xff,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0xff,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0xff,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0xff,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0xff,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0xff,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,
0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,
0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,
0x04,0x04,0x04,0x04,0x04,0x04,0x04,0x04,
0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,
0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,
};
unsigned char code Seril_Demo_Line1[]={
' ',' ',' ',' ','V','F','D','-','D','I','S','P','L','A','Y',' ',' ',' ',' ',' ',
};
unsigned char code Seril_Demo_Line2[]={
'M','O','D','E',':','S','E','R','I','A','L','-','D','E','M','O',' ',' ',' ',' ',
};
void delay(unsigned int t)
{
while(t--);
}
void code_send(unsigned char display_data_byte)
{
data_byte=display_data_byte;
SDATA=bit7; SCLK=0; SCLK=1;
SDATA=bit6; SCLK=0; SCLK=1;
SDATA=bit5; SCLK=0; SCLK=1;
SDATA=bit4; SCLK=0; SCLK=1;
SDATA=bit3; SCLK=0; SCLK=1;
SDATA=bit2; SCLK=0; SCLK=1;
SDATA=bit1; SCLK=0; SCLK=1;
SDATA=bit0; SCLK=0; SCLK=1;
delay(1); //delay 40us at least, according to the SPEC
}
void S_data_send(unsigned char temp_1)
{
STB=0;
code_send(0xfa);
code_send(temp_1);
STB=1;
}
void S_COM_send(unsigned char temp_2)
{
STB=0;
code_send(0xf8);
code_send(temp_2);
STB=1;
}
void main(void)
{
S_COM_send(0x01); //clear all display and set DD-RAM address 0 in address counter
S_COM_send(0x02); //move cursor to the original position
S_COM_send(0x06); //set the cursor direction increment and cursor shift enabled
S_COM_send(0x38); //set 8bit operation,2 line display and 100% brightness level
S_COM_send(0x80); //set cursor to the first position of 1st line
S_COM_send(0x0c); //set display on,cursor on,blinking off
delay(10);
for(j=0;j<13;j++)
{
/*********************************/
S_COM_send(0x40); //CGRAM ADDRESS SETTING
for(k=0;k<8;k++)
{
S_data_send(UDF[j][k]);
}
/*********************************/
S_COM_send(0x80); //DDRAM ADDRESS SETTING
for(i=0;i<80;i++)
{
S_data_send(0x00);
}
/*********************************/
delay(20000);
}
S_COM_send(0x80);
for(i=0;i<20;i++)
{
S_data_send(Seril_Demo_Line1[i]);
}
S_COM_send(0xc0);
for(i=0;i<20;i++)
{
S_data_send(Seril_Demo_Line2[i]);
}
delay(50000);
delay(50000);
delay(50000);
delay(50000);
delay(50000);
delay(50000);
delay(50000);
delay(50000);
delay(50000);
delay(50000);
/*********************************/
S_COM_send(0x80); //DDRAM ADDRESS SETTING
for(i=0;i<20;i++)
{
S_data_send(0x2a);
S_data_send(0x20);
}
for(i=0;i<20;i++)
{
S_data_send(0x20);
S_data_send(0x2a);
}
delay(50000);
delay(50000);
/*********************************/
S_COM_send(0x80); //DDRAM ADDRESS SETTING
for(i=0;i<20;i++)
{
S_data_send(0x20);
S_data_send(0x2a);
}
for(i=0;i<20;i++)
{
S_data_send(0x2a);
S_data_send(0x20);
}
delay(50000);
delay(50000);
/*********************************/
S_COM_send(0x40); //CGRAM ADDRESS SETTING
for(k=0;k<8;k++)
{
S_data_send(0xff);
}
S_COM_send(0x80); //DDRAM ADDRESS SETTING
for(i=0;i<80;i++)
{
S_data_send(0x00);
}
while(1);
}
|