/*AddLetters.c
Author:RanGuanghong
Date:2003.6.2
Vervion:1.0
Function:
Ocsillor:12.00Mhz.
CPU:w78e51
OSD device:uPD6453CY-001
OSD ocsillor:7.2Mhz,33pf.
*/
#include <reg51.h>
#ifndef uchar
#define uchar unsigned char
#endif
#ifndef uint
#define uint unsigned int
#endif
#define ReloadTh1 0xf4
#define ReloadTl1 0xf4
/*
I/O port.
*/
sbit Load=P1^0;
sbit Sclk=P1^1;
sbit BackGround=P1^2;
sbit Busy=P1^3;
sbit Clk=P1^4;
sbit Cs=P1^5;
sbit DataLine=P1^6;
sbit Led=P1^7;
/*
Parramenters.
*/
uchar bdata Flags=0;
sbit AddLetterFlag=Flags^0;
uchar data ReloadTh0=0xff;
uchar data ReloadTl0=0xbf;
uchar data ColumCounter=0;
uint data LedDelayTimer=65000;
uchar data ByteCounter=0;
uchar data DisplayControl=0;
uchar data BackgroundControl=0;
uchar data ProgressiveScanControl=0;
uint data DisplayPositionControl=0;
uint data CharacterWriteAddessControl=0;
/*
void Int1(void)
*/
void Int0(void) interrupt 0
{
EX0=0;
ET0=1;
while(1);
}
/*
void T0(void)
*/
void Timer0(void) interrupt 1
{
TR0=0;
ET0=0;
while(1);
}
/*
void Int0(void)
*/
void Int1(void) interrupt 2
{
EX1=0;
while(1);
}
/*
void Timer1(void)
*/
void Timer1(void) interrupt 3
{
TH1=ReloadTh1;
TL1=ReloadTl1;
while(1);
}
/*
void SerialPort(void)
*/
void SerialPort(void) interrupt 4
{
if(RI)
{
RI=0;
}
if(TI)
{
TI=0;
}
while(1);
}
/*
void WriteByte(uchar x)
*/
void WriteByte(uchar x)
{
uchar i,j;
j=x;
while(Busy);
for(i=0;i <8;i++)
{
Clk=0;
j < <=1;
DataLine=CY;
Clk=1;
}
}
/*
void WriteOneByte(uchar x)
*/
void WriteOneByte(uchar x)
{
uchar i;
i=x;
Cs=0;
WriteByte(i);
while(Busy);
Cs=1;
}
/*
void WriteTwoByte(uint x)
*/
void WriteTwoByte(uint x)
{
uchar i;
i=x/256;
Cs=0;
WriteByte(i);
i=x%256;
WriteByte(i);
while(Busy);
Cs=1;
}
/*
void WriteSecondByte(uint x)
*/
void WriteSecondByte(uint x)
{
uchar i;
i=x/256;
Cs=0;
WriteByte(i);
i=x%256;
WriteByte(i);
WriteByte(i);
while(Busy);
Cs=1;
}
/*
void WriteCharacterAddess(uchar x,uchar y,uchar Character)
x=1~12;
y=1~24;
Character=0~255;
*/
void WriteCharacter(uchar x,uchar y,uchar Character)
{
uint i=0;
i=i|0x8400;
if(x> =0x10)
{
i=i|0x0100;
}
i=i|(x < <5);
i=i|y;
WriteTwoByte(i);
i=0xca00;
i=i|Character;
WriteSecondByte(i);
}
void main(void)
{
uchar Temp=0;
P0=0x00;
P1=0xff;
P2=0x00;
P3=0xff;
Load=1;
Load=0;
IP=0x00;
IE=0x00;
TMOD=0x25;
TCON=0x05;
PCON=0x00;
SCON=0x00;
TH0=ReloadTh0;
TL0=ReloadTl0;
TH1=ReloadTh1;
TL1=ReloadTl1;
ES=1;
EX0=0;
EA=1;
while(1)
{
WriteOneByte(0x04); /*Display off,Osc on,Flink off.*/
WriteOneByte(0x40); /*No background.*/
WriteOneByte(0x1e); /*Background color:white.*/
WriteOneByte(0x30); /*Nomal TV scan.*/
WriteOneByte(0x34); /*Video RAM all reset.*/
WriteTwoByte(0x8088); /*Display position.*/
WriteCharacter(1,1,0x00);
WriteCharacter(1,2,0x01);
WriteCharacter(1,3,0x02);
WriteCharacter(1,4,0x03);
WriteCharacter(1,5,0x04);
WriteCharacter(1,6,0x05);
WriteCharacter(1,7,0x06);
WriteCharacter(1,8,0x07);
WriteCharacter(1,9,0x08);
WriteCharacter(4,1,0x00);
WriteCharacter(4,2,0x01);
WriteCharacter(4,3,0x02);
WriteCharacter(4,4,0x03);
WriteCharacter(4,5,0x04);
WriteCharacter(4,6,0x05);
WriteCharacter(4,7,0x06);
WriteCharacter(4,8,0x07);
WriteCharacter(4,9,0x08);
WriteCharacter(8,1,0x00);
WriteCharacter(8,2,0x01);
WriteCharacter(8,3,0x02);
WriteCharacter(8,4,0x03);
WriteCharacter(8,5,0x04);
WriteCharacter(8,6,0x05);
WriteCharacter(8,7,0x06);
WriteCharacter(8,8,0x07);
WriteCharacter(8,9,0x08);
//WriteTwoByte(0x8800); /*Size,Smooth,Mask pule control.*/
WriteOneByte(0x0c); /*Display on,Osc on,Flink off.*/
Cs=0;
while(1)
{
if(LedDelayTimer==0)
{
Led=~Led;
LedDelayTimer=65000;
}
else
{
LedDelayTimer--;
}
}
}
}