www.pudn.com > 8255Adianzheng.zip > main.c, change:2012-12-10,size:1279b


#include<reg52.h> 
#include<absacc.h> 
 
//sbit DS=P2^0;   
//sbit SH_CP=P2^1; 
//sbit ST_CP=P2^2; 
//sbit AB=P2^4; 
//sbit SCK=P2^5; 
#define A XBYTE[0xff7c]     //8255A  A口  控制寄存器的地址 
#define B XBYTE[0xff7d]     //8255A  B口  控制寄存器的地址 
#define C XBYTE[0xff7e]     //8255A  C口  控制寄存器的地址 
#define Com XBYTE[0xff7f]   //8255A 控制寄存器的地址 
 
unsigned char i,j; 
 
code unsigned char CHONG[32]={/*"重",0*/ 
0xFE,0x07,0xC0,0x7F,0xFE,0x7F,0x00,0x00, 
0xFE,0x7F,0xE0,0x07,0xE6,0x67,0xE0,0x07, 
0xE6,0x67,0xE0,0x07,0xFE,0x7F,0xC0,0x03, 
0xFE,0x7F,0xFE,0x7F,0x00,0x00,0xFF,0xFF, 
/* (16 X 16 , 宋体, 加粗 )*/ 
}; 
void  delay(int t) 
{ 
	int i,j; 
	for(i=t;i>0;i--) 
		for(j=110;j>0;j--); 
} 
 
void WriteByte(unsigned char dat)   
{  
	Com=0x80; 
	for(i=0;i<8;i++) 
	{ 
	  dat=dat>>1; 
	  //DS=CY; 
	  B=CY&0X01; 
	  delay(1);     
	  //SH_CP=0;  
	  //SH_CP=1; 
	  B=0X00; 
	  delay(1); 
	  B=0X02; 
	} 
} 
 
void display() 
{ 
	Com=0x80; 
	//AB=0; 
	delay(1); 
	B=0X00; 
	for(j=0;j<16;j++) 
	{ 
		//SCK=0; 
		B=0X00; 
		delay(1);	 
		WriteByte(CHONG[2*j+1]);   
		WriteByte(CHONG[2*j]); 
		//SCK=1; 
		//AB=1; 
		//ST_CP=0; 
		B=0XF0; 
		delay(1); 
		//ST_CP=1; 
		B=0X04; 
		delay(1);	 
	} 
} 
 
void main() 
{	 
	while(1) 
	{	 
		display(); 
	}   
}