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

📄 lcd.c

📁 我自己写的44B0+uclinux驱动12864点阵式LCD的显示程序,适合于做小工程的程序员使用
💻 C
字号:
/**********************************************/
#include <stdlib.h>
#include <stdio.h>

#define write_coml 	0x00000200      	///1      0     1     0     0      1     0    0	//左半屏命令地址
#define write_comr 	0x00000800		///1      0     1     0     1      0     0    0	//右半屏命令地址
#define write_datl 	0x00000300		///1      0     1     0     0      1     0    1	//左半屏数据地址
#define write_datr 	0x00000900	///1      0     1     0     1      0     0    1	//右半屏数据地址


#define rPCONC (*(volatile unsigned *)0x1d20010)
#define rPDATC (*(volatile unsigned *)0x1d20014)
#define rPUPC   (*(volatile unsigned *)0x1d20018)




#define 		SA1 0xb8 			//第一行(竖向16点作为一行,即一个字的一竖要送2次)
#define 		SA2 0xba 			//第二行
#define 		SA3 0xbc 			//第三行
#define 		SA4 0xbe 			//第四行

unsigned char  lcdzm[65];	

//"请",0
unsigned char  GB_16[32]=          // 数据表
     { 0x20,0x22,0xEC,0x00,0x20,0x22,0xAA,0xAA,
      0xAA,0xBF,0xAA,0xAA,0xAA,0x22,0x20,0x00,
      0x00,0x00,0x7F,0x20,0x10,0x00,0xFF,0x0A,
      0x0A,0x0A,0x4A,0x8A,0x7F,0x00,0x00,0x00};


/**********************************************/
void LCD_NOP(void)
{
 	unsigned int  m;
	for(m=0;m<2000;m++);  
}

void LCD_Write(unsigned int  add,unsigned int x)
{ 
	unsigned char temp;
	unsigned int   temp2;
    
  	temp = x ;
	temp2=add ;
	rPDATC=add;
	LCD_NOP();
	rPDATC=add|temp;
	LCD_NOP();
}


//-------------------------------------------- Scan lcd pro -----------------------------------------
void ScanLCD16 ( unsigned char lcdhang,unsigned char lcdaddr,unsigned char * lcddata )//16*16
{
	unsigned int  block1, colum1 ;
    unsigned int  display_a0;
    unsigned int  i,j;

    if( lcdaddr < 64 )
    {
        block1=lcdhang;                    
		LCD_Write( write_coml,block1 ) ;
		colum1 = 0x40 + lcdaddr ;
		LCD_Write( write_coml,colum1 ) ;

        j=0;
		display_a0 = lcddata[j] ;
		for(i=0;i<16;i++)
		{
		    LCD_Write( write_datl,display_a0 );
			j++ ;
			display_a0 = lcddata[j] ;
		}

        block1=lcdhang+1;                    
		LCD_Write( write_coml,block1 ) ;
		colum1 = 0x40 + lcdaddr ;
		LCD_Write( write_coml,colum1 ) ;

        j=0;
		display_a0 = lcddata[j+16] ;
		for(i=0;i<16;i++)
		{
		    LCD_Write( write_datl,display_a0 );
			j++ ;
			display_a0 = lcddata[j+16] ;
		}
     }
     else 
     {
        lcdaddr = lcdaddr - 64 ;         

       	block1=lcdhang;                    
		LCD_Write( write_comr,block1 ) ;
		colum1 = 0x40 + lcdaddr ;
		LCD_Write( write_comr,colum1 ) ;

        j=0;
		display_a0 = lcddata[j] ;
		for(i=0;i<16;i++)
		{
		    LCD_Write( write_datr,display_a0 );
			j++ ;
			display_a0 = lcddata[j] ;
		}

        block1=lcdhang+1;                    
		LCD_Write( write_comr,block1 ) ;
		colum1 = 0x40 + lcdaddr ;
		LCD_Write( write_comr,colum1 ) ;

        j=0;
		display_a0 = lcddata[j+16] ;
		for(i=0;i<16;i++)
		{
		    LCD_Write( write_datr,display_a0 );
			j++ ;
			display_a0 = lcddata[j+16] ;
		}
     }

     for(i=0;i<65;i++)lcdzm[i]=0;
     
}






void make_lcd ( void )
{
	unsigned char comm ;
	comm = 0x3f ;                 //显示开关设置
	LCD_Write ( write_coml,comm ) ;
	
	LCD_Write ( write_comr,comm ) ;
	comm = 0xc0 ;                 //设置起始行设置 1-64 0-3FH
	LCD_Write ( write_coml,comm ) ;
	LCD_Write ( write_comr,comm ) ;
	comm = 0xb8 ;                 //页面地址设置 共8页
	LCD_Write ( write_coml,comm ) ;
	LCD_Write ( write_comr,comm ) ;
	comm = 0x40 ;                 //列地址设置 共1-64 0-3FH
	LCD_Write ( write_coml,comm ) ;
	LCD_Write ( write_comr,comm ) ;
}

int  main()
{
  int a,i,j;
  unsigned int contemp;
  contemp=rPCONC&0xffc00000;
  rPCONC = contemp|0x155555;
    printf("%x\n",rPCONC);
 // LCD_Write(write_datr,0xaa);
 // rPUPC  = 0x3000;
 printf("start to display\n");
  make_lcd();

		  for( j=0; j<32; j++ )
				{
					lcdzm[j] = GB_16[j];
				}
		 ScanLCD16(SA1,0,lcdzm); 
		 
 while(1);
        
  
}

⌨️ 快捷键说明

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