⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 62256tiao.i

📁 使用OKI公司8255A控制62256RAM程序,并使用8803液晶显示
💻 I
📖 第 1 页 / 共 2 页
字号:
   unsigned int sum;
   dat=0x80+dat*4;                                 //得到实际地址

   sum=(unsigned int)(x_h)*(unsigned int)(30)+(unsigned int)y_l;					   //得到当前字符位置
   y_l=sum%256;                                    //得到显示列数
   x_h=sum/256;									   //得到显示行数
   Send_lcd(2,y_l,x_h,0x24);					   //置显示地址
   Send_lcd(1,dat,0x00,0xc0);					   //送显示值--汉字左上部分 
   Send_lcd(1,dat+2,0x00,0xc0);					   //送显示值--汉字右上部分
   sum=sum+30;							   //修正下半部分字符位置
   y_l=sum%256;									   //得到显示列数
   x_h=sum/256;									   //得到显示行数
   Send_lcd(2,y_l,x_h,0x24);					   //置显示地址
   Send_lcd(1,dat+1,0x00,0xc0);					   //送显示值--汉字左下部分 
   Send_lcd(1,dat+3,0x00,0xc0);					   //送显示值--汉字右下部分
   Send_lcd(2,0,0,0x24);
}

//************************************
//画实点函数
//说明:该函数可以产行屏幕上的任意位置上的点,输入参数,X:行坐标(0-127)Y:列坐标(0-239)
//************************************ 

void point(unsigned char X,unsigned char Y)
{
   unsigned int Sum;						       
   Sum=(unsigned int)(X)*(unsigned int)(30)*8+(unsigned int)Y;							   //得到当单位置前的点阵和
   Send_lcd(2,Sum/8,Sum/2048+0x08,0x24);		   //换算出实际行列坐标,并将操作地址写入lcd
   Send_lcd(0,0x00,0x00,(0x07-Y%8)|0xf8); 		   //换算出当前位,将该位置1显示
} /**/
//*************************************

//*************************************
//画直线函数
//说明:需要用到画实心点函数Point(x,y),无需借助全局变量
//传入参数:x1,y1:直线起点行列坐标值(0<=x1<=127)(0<=y1<=239)
//传入参数:x2,y2:直线终点行列坐标值(0<=x2<=127)(0<=y2<=239)
//提示:本函数数支持斜率为0和无穷大直线的描绘,当起点和终点相同量,将产生一个实心点
//************************************* 

void Line(unsigned char x1,unsigned char y1,unsigned char x2,unsigned char y2)
{
   unsigned char temp,i;
   float k;
   signed char j;				   
   if(y1>y2){temp=x2;x2=x1;x1=temp;temp=y2;y2=y1;y1=temp;}    //变换次序,得到y2>y1的形式;
   if(y1==y2)												  //当斜率无穷时
     {
	   if(x1>x2)											  //对行坐标排序
	     {for(i=x2;i<=x1;i++)point(i,y1);}					  //画竖线从上到下
	   else
	     {for(i=x1;i<=x2;i++)point(i,y1);}	 
	 }
   else														  //当斜率为有限值时
   {  
      k=(float)y1-y2;									      //得到列差
	  j=x2-x1;												  //得到行差
      k=(float)j/k;	  	  	  								  //得到直线斜率
      if(k==0)												  //当斜率为零时
        {for(i=y1;i<=y2;i++)point(x1,i);}					  //从左至右画直线
      else													  //当斜率不为零时
	    {for(i=y1;i<=y2;i++)point(x1-(i-y1)*k,i);}	 	 	  //按列值从左至右画直线	
    }
}       /* */
//**************************************



//**********************************************************************************************************
//画直角坐标系
//说明:本函数功能的实现要用到画实心点函数Point(x,y),Line(x1,y1,x2,y2)无需用到全局变量参数
//传入参数:xo,yo:直角坐标系的原点行列坐标值,x_t,y_t:直角坐标系竖轴和横轴的长度值
//传入参数:x,y:直角坐标系的竖轴和横轴上该度间距,mark:直角坐标系标志:mark=0时,将以起点坐标为原点仅画出第一象限,
//         mark=1时将以起点坐标为原点画出四象限坐标系,但会占满全屏幕,并且x_t和y_t此时将被忽略
//提示:当x和y值超过240时,将会失去轴线上的该度标识,本函数画出的坐标系在轴的末端带有实心箭步头
//********************************************************************************************************** 
/*
void Zjzb(unsigned char xo,unsigned char yo,unsigned char x_t,unsigned char y_t,unsigned char x,unsigned char y,unsigned char mark)
{
    unsigned char P_x,P_y,i;
	P_x=xo-x_t;											 //得到竖轴终点行坐标值
	P_y=yo+y_t;											 //得到横轴终点列坐标值
    switch (mark)										 //判断坐标系的类型
	  {
	      case 0: 										 //第一象限坐标系
		      Line(xo,yo,P_x,yo);Line(xo,yo,xo,P_y);	 //画纵轴和横轴
			  //------------------------------------------纵轴末端打箭头
			  P_x+=1;Point(P_x,yo-1);Point(P_x,yo+1);
			  P_x+=1;Point(P_x,yo-2);Point(P_x,yo-1);
			  Point(P_x,yo+1);Point(P_x,yo+2);	  
			  //------------------------------------------横轴末端打箭头
			  P_y-=1;Point(xo-1,P_y);Point(xo+1,P_y);
			  P_y-=1;Point(xo-2,P_y);Point(xo-1,P_y);
			  Point(xo+1,P_y);Point(xo+2,P_y);	  
			  //--------------------------------------------
			  P_x=(x_t-3)/x;							  //得到竖轴刻度标志总数
			  for(i=0;i<=P_x;i++)						  //画竖轴刻度标志
			     {Point(xo-i*x,yo+1);Point(xo-i*x,yo+2);Point(xo-i*x,yo+3);}
		      P_y=(y_t-3)/y;							  //得到横轴刻度标志总数
			  for(i=0;i<=P_y;i++)						  //画横轴刻度标志
			     {Point(xo-1,yo+i*y);Point(xo-2,yo+i*y);Point(xo-3,yo+i*y);}
			  break;
		  	  //-------------------------------------------			  
		  case 1:										  //四象限坐标系
		       Line(0,yo,127,yo);Line(xo,0,xo,239);       //画横竖轴
			   break; 
	      default:break;	  
	  }
}   */
//***********************************************************************************************************
// CodeVisionAVR C Compiler
// (C) 1998-2001 Pavel Haiduc, HP InfoTech S.R.L.

// I/O registers definitions for the ATmega16






// CodeVisionAVR C Compiler
// (C) 1998-2000 Pavel Haiduc, HP InfoTech S.R.L.





void fasong(unsigned char );
void fasong(unsigned char );
void fasong(unsigned char );
void fasong(unsigned char );
void usart(void)                 //USART初始化
{DDRD.0=1;
 DDRD.1=1; 
 
 UBRRH=0x80;
 UBRRL=0x35;//波特率9600 ;此时的晶振的频率为8MHz
 //UBRRL=0x9; 
 //UBRRH=0x00;
 //UBRRL=0x8;//波特率57600;此时的晶振的频率为8MHz    
 
 UCSRB=0x90;                     //数据位为8位 
 UCSRC=0x86;                     //10000110  :异步工作方式,1位停止位
 UCSRB|=0x10;       //准许接受数据
 
 fasong(10);
 fasong(10);
}
void fasong(unsigned char m)		 //串口发送
{//UCSRA&=0X20 
 while(!(UCSRA&0X20));           //是否发送完;
 UCSRB|=8;  
 UDR=m;
   
}  

unsigned char receive()
{while(!(UCSRA&0x80)); //等待接受完毕
 UCSRB&=0x7F;//清除 
 UCSRB|=0x10;
 return UDR;
 }/* */
 /**/
void fasong_int(int w)
{unsigned char temp=0;
 if(w<0){fasong(45);w=-w;}
 w=(unsigned int)w;
 temp=w/10000; 
 fasong(temp+48); 
 w=w%10000;
 
 
 temp=w/1000; 
 fasong(temp+48);
 w=w%1000; 


 temp=w/100; 
 fasong(temp+48); 
 w=w%100;
 
 
 temp=w/10; 
 fasong(temp+48);
 w=w%10;

 
 temp=w;
 fasong(temp+48); 
 
 //fasong(9);//发送完毕之后退格
 fasong(10);//发送完毕之后回车
 }  
void fasong_long(unsigned long w)
{unsigned char i=0;
 unsigned char a[10];
 unsigned char si=0;
 a[0]=0;
 for(i=0;i<10;i++)
 {a[i]=w%10;
  w=w/10;
  if(a[i]>0)si=i;
  }
 for(i=si;i>0;i--)fasong(a[i]+48);
  fasong(a[0]+48); 
  fasong(10);
 } 
 
   
/*
CodeVisionAVR C Compiler
Prototypes for mathematical functions

Portions (C) 1998-2001 Pavel Haiduc, HP InfoTech S.R.L.
Portions (C) 2000-2001 Yuri G. Salov
*/



#pragma used+

unsigned char cabs(signed char x);
unsigned int abs(int x);
unsigned long labs(long x);
float fabs(float x);
signed char cmax(signed char a,signed char b);
int max(int a,int b);
long lmax(long a,long b);
float fmax(float a,float b);
signed char cmin(signed char a,signed char b);
int min(int a,int b);
long lmin(long a,long b);
float fmin(float a,float b);
signed char csign(signed char x);
signed char sign(int x);
signed char lsign(long x);
signed char fsign(float x);
unsigned char isqrt(unsigned int x);
unsigned int lsqrt(unsigned long x);
float sqrt(float x);
float floor(float x);
float ceil(float x);
float fmod(float x,float y);
float modf(float x,float *ipart);
float ldexp(float x,int expon);
float frexp(float x,int *expon);
float exp(float x);
float log(float x);
float log10(float x);
float pow(float x,float y);
float sin(float x);
float cos(float x);
float tan(float x);
float sinh(float x);
float cosh(float x);
float tanh(float x);
float asin(float x);
float acos(float x);
float atan(float x);
float atan2(float y,float x);

#pragma used-
#pragma library math.lib


unsigned int jh3=0; 
unsigned int dress=0;
unsigned char temp=0;
unsigned int readadc(unsigned char channel) 
{ADMUX=channel;             
 ADMUX|= 0x40;
 ADCSRA|=0x40;  //注意选择手动转换,那么必须在每次转换完成之后再将ADSC=1 启动一下 
 while((ADCSRA&0x10)!=0x10);
 return ADCW;
}
main()
{unsigned int k=0; 
 unsigned int w=0; 
 unsigned int temp=0; 
 unsigned char i=0;
 unsigned char x=0;
 unsigned char y=0;
 unsigned char x1=0;
 unsigned char y1=0;
 unsigned long  rubbish=12; 
 float jh=1.2254;  
 xianshi(12345678,0);
 DDRA=0x00;
 PORTA=0x00;
 DDRD=0xff;
 PORTA.6=1;
 ADMUX=0x40; 
 ADCSRA=192;
 DDRA.7=1;
 PORTA.7=1;
 delay_ms(200);
 #asm("sei")
 
 rest8255(0x80);
 usart(); 
 send8255(0xff,0);
 send8255(0xff,1);
 send8255(0xff,2);
 rest_lcd();
 for(i=0;i<8;i++)chinese(0,6+2*i,i); 
 for(i=0;i<7;i++)chinese(2,2*i,i+8); 
 next:
 temp=0; 
 x=12;
 k=13;
 
 TCCR1A=0x00;
 TCCR1B=0x02;
 //jh=sin(jh);
 //jh=jh*2.35689;
 //k=k+87;
 //k=k+87;
 //k=k+87;
 //k=k+87;
 //jh=sqrt(28.5);
 //x=x*6;
 //xianshi(2345678,0); 
 //rubbish=rubbish/20;
 //x1=readadc(0);
 //x1=readadc(0);
 //xianshi(k,2);
 //chinese(2,2,8);
 k=TCNT1; 
 //k=12345;
 xianshi(k,0);
 
 /**/
 //开始接收数据
 k=0;
 while(PINA.6);
 /* {//x1=receive();
  
  //writeram(k,x1);
  if(jh3!=0)
  {xianshi(1314584,0);
   jh3=0;
   k=UDR;
   }
  //delay_ms(1000);
  k++;
   
  }
 xianshi(0xf0,0); 
 while(PINA.6); 
 xianshi(dress,0);
 delay_ms(3000); 
 k=0; 
 while(1)
 {
  y1=readram(k);
  xianshi(y1,0);
  k++;  
  delay_ms(1000); 
  }
 
 
 //接收数据完毕
 while(PINA.6); 
 xianshi(jh*1000000,6);
 delay_ms(1000);
 while(PINA.6); 
 */
 while(temp<10000)
 {k=readadc(0);//0xaabb;
  i=k;
  writeram(temp,i);
  i=k>>8;
  writeram(temp+1,i);
  temp+=2;  
 } 
 
  
 temp=0; 
 xianshi(87654321,0);
 point(0,2);
 //开始画图 
 
 while(temp<481)
 {k=readram(temp+1);
  k=k<<8;
  
  k=k+readram(temp);
  xianshi(k,0);
  //delay_ms(300);
  temp+=2; 
  if(k!=0)
  {x=128-k/8;
   point(x,y);
   xianshi(k,0);
   delay_ms(50);
  } 
  if(y==240)
  {
  while(PINA.6);
  y=0;
  }
   
  else x=128;
  temp+=2; 
  y++;
 } 
/* 
 temp=0;
 while(temp<10000)
 {k=readram(temp+1);
  k=k<<8;
  k=k+readram(temp);
  if(k!=0)
  {x=128-k/8;
   point(x,y);
   xianshi(k,0);
   delay_ms(50);
  } 
  if(y==240)
  {
  while(PINA.6);
  y=0;
  }
   
  else x=128;
  temp+=2; 
  y++;
  
 } 
 temp=0;
 while(1);
 while(temp<32000)
 {k=readram(temp);
  xianshi((long)temp*1000+k,0); 
  fasong(k);
  if(k!=0x25)
  {
   w++;
    }
  //xianshi(k,0);
  temp++; 
  delay_ms(100);
 }
 */  
 xianshi(w,0);
 w=0;
 delay_ms(100); 
 goto next; 
 while(1);
 }    
interrupt [12] RXINT() //接受数据完毕中断
{temp=UDR;
 writeram(dress,temp);
 dress++;
 } 

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -