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

📄 3310.c.bak

📁 两个C51测试3310的源程序其中一个移植朋友网站上的AVR例程。芯片用STC89LE58RD+
💻 BAK
字号:
/* 3310液晶显示屏C51测试程序 
接脚资料: 
Pin Signal Description Port 
1:VDD 
Power Input. Logic supply voltage range VDD to GND : 2.7 to 3.3 V 
2:SCLK 
Serial clock. Input for the clock signal: 0.0 to 4.0 Mbits/s. 
3:SDIN 
Serial data. Input for the data line. 
4:D/C 
Mode Select. To select either command/address or data input. 
5:SCE 
Chip enable input. The enable pin allows data to be clocked in. The signal is 
active LOW. 
6:GND 
Ground 
7:VOUT 
Ouptut voltage. Add external 1-10 uF electrolytic capacitor from VOUT to GND 
8:RES 
External reset. This signal will reset the device and must be applied to 
properly 
initialize the chip. The signal is active LOW. 
控制芯片: 
PCD8544 
宽×高(像素): 84×48 
*/ 

#include <reg52.h>
#define uchar unsigned char 
#define uint unsigned int 

sbit sclk=P2^0;//时钟 
sbit sdin=P2^1; //数据 
sbit dc=P2^2;//1写数据,0写指令 
sbit sce=P2^3;//片选 
sbit res=P2^4;//复位,0复位 

/*void write_byte(uchar dd,bit a)//写一字节
{
 char i;
   sce=0;
   dc=a;
   for(i=7;i>=0;i--)
    {    
  sdin=(dd>>i)&1;
     sclk=0;
     sclk=1;    
     }
   dc=1;
  sce=1;
sdin=1;
}*/

//---------------------超快,但多了135字-----------------------------
unsigned char mask_table[8]={0x80,0x40,0x20,0x10,0x08,0x04,0x02,0x01};

void write_byte(uchar dd,bit a)//写一字节
{
char i; 
   sce=0;
   dc=a;
   for(i=0;i<8;i++)
    {  
     if(dd&mask_table[i])
     sdin=1;
     else
	 sdin=0;
     sclk=0;     
     sclk=1;    
     }
   dc=1;
  sce=1;
sdin=1;
}




void setadd(unsigned char a,unsigned char d)//设定地址
{
  write_byte((d|0x40),0);
        write_byte((a|0x80),0);
}

void qp()//清屏
{
uchar t;
uchar k;
uint d; 
d=0; 
for(t=0;t<6;t++)
{   
      for(k=0;k<84;k++)
      {       
       write_byte(0,1);
       d=d+1;       
      } 
     }
}

uchar code dal[]=
{
/*------------------------------------------------------------------------------
;  源文件 / 文字 : E:\3310\1\qq.bmp模
;  宽×高(像素): 84×48
;  字模格式/大小 : 单色点阵液晶字模,纵向取模,字节倒序/504字节
;  数据转换日期  : 2004-7-30 13:40:24*/
0x00,0x00,0x02,0xFA,0x8A,0x8A,0x8A,0xFA,0x02,0x02,0xFE,0x03,0x02,0x00,0x40,0x4F,
0xC9,0x79,0x49,0xCF,0x00,0xFC,0x00,0x00,0xFF,0x00,0x02,0x82,0x02,0xBE,0x22,0x63,
0xA2,0x22,0x22,0xA2,0x02,0x00,0x00,0x01,0x01,0x01,0x01,0xF9,0x09,0x05,0x03,0x01,
0x00,0x00,0x10,0x14,0x14,0x94,0xD4,0xBF,0x94,0x5C,0x54,0x12,0x10,0x00,0x00,0xFF,
0x29,0x29,0xFF,0x00,0xFF,0x29,0x29,0xFF,0x00,0x00,0x04,0x04,0x04,0xC4,0x3F,0xD4,
0x14,0x94,0x74,0x06,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x01,0x04,0x04,0x07,0x00,
0x00,0x00,0x04,0x02,0x01,0x04,0x04,0x03,0x00,0x01,0x04,0x04,0x07,0x00,0x02,0x01,
0x00,0x07,0x04,0x04,0x05,0x04,0x06,0x00,0x03,0x00,0x00,0x80,0x40,0x44,0x84,0x07,
0x00,0x00,0x00,0x00,0x00,0x00,0x02,0x92,0x51,0x30,0x37,0x14,0x14,0x14,0x04,0x07,
0x00,0x00,0x26,0x21,0x44,0x84,0x07,0x02,0x01,0x04,0x04,0x07,0x00,0x00,0x04,0x02,
0x05,0x04,0x04,0x02,0x01,0x02,0x02,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x30,0x48,0x88,0x10,0x60,0x78,0x04,0x04,0xF8,0x00,0x00,0x00,0x00,0x00,0x1C,0xE2,
0x02,0x04,0x08,0x04,0x84,0x84,0x82,0x02,0x02,0x02,0x01,0x81,0x41,0x21,0x21,0x20,
0x00,0x04,0x07,0x18,0x60,0x80,0x00,0x00,0xF0,0x0C,0x03,0x00,0xFC,0x00,0x00,0x04,
0x0E,0x04,0xC0,0x60,0x62,0x37,0x12,0x90,0x16,0x19,0x7A,0xFC,0xF8,0xF0,0x80,0x40,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x07,0x08,0x10,0xE0,0x00,0x00,0x00,0xF8,0x07,0x00,0x00,
0x02,0x12,0x12,0x1F,0xF4,0xA0,0x00,0x00,0x00,0x40,0x80,0x81,0x8C,0x5C,0x3C,0x2C,
0x40,0x40,0x40,0x20,0x00,0x00,0x80,0xC0,0x64,0x5F,0x45,0xC9,0x83,0x04,0x04,0x04,
0x1B,0x20,0x40,0x80,0x80,0x01,0x00,0x00,0x00,0x00,0x10,0x14,0x23,0x21,0xA1,0x51,
0xF1,0x3F,0x12,0xE2,0x40,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x03,0x0C,0x10,0x20,
0x21,0x22,0x22,0x22,0x7F,0x41,0x41,0x47,0x49,0xCB,0x0F,0x06,0x06,0x04,0x0C,0x1C,
0x14,0x34,0x24,0x24,0x14,0x14,0x12,0x0A,0x06,0x01,0x00,0x00,0x00,0x00,0xE0,0x20,
0x2F,0xF0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x01,0x01,0x01,0x01,0x01,0x01,
0x01,0x01,0x00,0x00,0xF8,0x21,0x21,0x40,0x40,0x20,0xD1,0x8A,0x0C,0x10,0x20,0xC0,
0x00,0x00,0x00,0x00,0x00,0x20,0x00,0x20,0x00,0x20,0x00,0x20,0x00,0x20,0x00,0x20,
0x00,0x20,0x00,0x20,0x00,0x20,0x00,0x20,0x00,0x20,0x00,0x20,0x00,0x20,0x1F,0x20,
0x00,0x20,0x00,0x20,0x00,0x20,0x00,0x20,0x00,0x20,0x00,0x20,0x00,0x20,0x00,0x20,
0x00,0x20,0x07,0x38,0x00,0x3F,0x00,0x20,0x00,0x20,0x00,0x20,0x00,0x20,0x00,0x20,
0x00,0x20,0x00,0x20,0x00,0x20,0x00,0x20,0x07,0x38,0x04,0x22,0x01,0x31,0x10,0x28,
0x08,0x24,0x04,0x23,0x00,0x20,0x00,0x20
};

void xp()//写一屏图
{
uchar e;
uchar t;
uchar k;
uint d; 
   d=0; 
   for(t=0;t<6;t++)
    {   
      for(k=0;k<84;k++)
      { 
    	e=dal[d];      
       	write_byte(e,1);
       	d=d+1;       
      }  
    }  
}


uchar code dal1[][6]={//static const byte FontLookup [][6]
{0x00,0x00,0x00,0x00,0x00,0x00},  // sp 0
{0x00,0x00,0x2f,0x00,0x00,0x00},   // ! 1
{0x00,0x07,0x00,0x07,0x00,0x00},   // " 2 
{0x14,0x7f,0x14,0x7f,0x14,0x00},   // # 3
{0x24,0x2a,0x7f,0x2a,0x12,0x00},   // $ 4
{0xc4,0xc8,0x10,0x26,0x46,0x00},   // % 5
{0x36,0x49,0x55,0x22,0x50,0x00},   // & 6 
{0x00,0x05,0x03,0x00,0x00,0x00},   // ' 7
{0x00,0x1c,0x22,0x41,0x00,0x00},   // ( 8
{0x00,0x41,0x22,0x1c,0x00,0x00},   // ) 9
{0x14,0x08,0x3E,0x08,0x14,0x00},   // * 10
{0x08,0x08,0x3E,0x08,0x08,0x00},   // + 11
{0x00,0x00,0x50,0x30,0x00,0x00},   // , 12 
{0x10,0x10,0x10,0x10,0x10,0x00},   // - 13
{0x00,0x60,0x60,0x00,0x00,0x00},   // . 14
{0x20,0x10,0x08,0x04,0x02,0x00},   // / 15
{0x3E,0x51,0x49,0x45,0x3E,0x00},   // 0 16
{0x00,0x42,0x7F,0x40,0x00,0x00},   // 1 17
{0x42,0x61,0x51,0x49,0x46,0x00},   // 2 18
{0x21,0x41,0x45,0x4B,0x31,0x00},   // 3 19
{0x18,0x14,0x12,0x7F,0x10,0x00},   // 4 20
{0x27,0x45,0x45,0x45,0x39,0x00},   // 5 21
{0x3C,0x4A,0x49,0x49,0x30,0x00},   // 6 22
{0x01,0x71,0x09,0x05,0x03,0x00},   // 7 23
{0x36,0x49,0x49,0x49,0x36,0x00},   // 8 24
{0x06,0x49,0x49,0x29,0x1E,0x00},   // 9 25
{0x00,0x36,0x36,0x00,0x00,0x00},   // : 26
{0x00,0x56,0x36,0x00,0x00,0x00},   // ; 27
{0x08,0x14,0x22,0x41,0x00,0x00},   // < 28
{0x14,0x14,0x14,0x14,0x14,0x00},   // = 29
{0x00,0x41,0x22,0x14,0x08,0x00},   // > 30
{0x02,0x01,0x51,0x09,0x06,0x00},   // ? 31
{0x32,0x49,0x59,0x51,0x3E,0x00},   // @ 32
{0x7E,0x11,0x11,0x11,0x7E,0x00},   // A 33
{0x7F,0x49,0x49,0x49,0x36,0x00},   // B 34
{0x3E,0x41,0x41,0x41,0x22,0x00},   // C 35
{0x7F,0x41,0x41,0x22,0x1C,0x00},   // D 36
{0x7F,0x49,0x49,0x49,0x41,0x00},   // E 37
{0x7F,0x09,0x09,0x09,0x01,0x00},   // F 38
{0x3E,0x41,0x49,0x49,0x7A,0x00},   // G 39
{0x7F,0x08,0x08,0x08,0x7F,0x00},   // H 40
{0x00,0x41,0x7F,0x41,0x00,0x00},   // I 41
{0x20,0x40,0x41,0x3F,0x01,0x00},   // J 42
{0x7F,0x08,0x14,0x22,0x41,0x00},   // K 43
{0x7F,0x40,0x40,0x40,0x40,0x00},   // L 44
{0x7F,0x02,0x0C,0x02,0x7F,0x00},   // M 45
{0x7F,0x04,0x08,0x10,0x7F,0x00},   // N 46
{0x3E,0x41,0x41,0x41,0x3E,0x00},   // O 47
{0x7F,0x09,0x09,0x09,0x06,0x00},   // P 48
{0x3E,0x41,0x51,0x21,0x5E,0x00},   // Q 49
{0x7F,0x09,0x19,0x29,0x46,0x00},   // R 50
{0x46,0x49,0x49,0x49,0x31,0x00},   // S 51
{0x01,0x01,0x7F,0x01,0x01,0x00},   // T 52
{0x3F,0x40,0x40,0x40,0x3F,0x00},   // U 53
{0x1F,0x20,0x40,0x20,0x1F,0x00},   // V 54
{0x3F,0x40,0x38,0x40,0x3F,0x00},   // W 55
{0x63,0x14,0x08,0x14,0x63,0x00},   // X 56
{0x07,0x08,0x70,0x08,0x07,0x00},   // Y 57
{0x61,0x51,0x49,0x45,0x43,0x00},   // Z 58
{0x00,0x7F,0x41,0x41,0x00,0x00},   // [ 59
{0x55,0x2A,0x55,0x2A,0x55,0x00},   //55 60
{0x00,0x41,0x41,0x7F,0x00,0x00},   // ] 61
{0x04,0x02,0x01,0x02,0x04,0x00},   // ^ 62
{0x40,0x40,0x40,0x40,0x40,0x00},   // _ 63
{0x00,0x01,0x02,0x04,0x00,0x00},   // ' 64
{0x20,0x54,0x54,0x54,0x78,0x00},   // a 65
{0x7F,0x48,0x44,0x44,0x38,0x00},   // b 66
{0x38,0x44,0x44,0x44,0x20,0x00},   // c 67
{0x38,0x44,0x44,0x48,0x7F,0x00},   // d 68
{0x38,0x54,0x54,0x54,0x18,0x00},   // e 69
{0x08,0x7E,0x09,0x01,0x02,0x00},   // f 70 
{0x0C,0x52,0x52,0x52,0x3E,0x00},   // g 71 
{0x7F,0x08,0x04,0x04,0x78,0x00},   // h 72
{0x00,0x44,0x7D,0x40,0x00,0x00},   // i 73
{0x20,0x40,0x44,0x3D,0x00,0x00},   // j 74
{0x7F,0x10,0x28,0x44,0x00,0x00},   // k 75
{0x00,0x41,0x7F,0x40,0x00,0x00},   // l 76
{0x7C,0x04,0x18,0x04,0x78,0x00},   // m 77
{0x7C,0x08,0x04,0x04,0x78,0x00},   // n 78
{0x38,0x44,0x44,0x44,0x38,0x00},   // o 79
{0x7C,0x14,0x14,0x14,0x08,0x00},   // p 80
{0x08,0x14,0x14,0x18,0x7C,0x00},   // q 81
{0x7C,0x08,0x04,0x04,0x08,0x00},   // r 82
{0x48,0x54,0x54,0x54,0x20,0x00},   // s 83
{0x04,0x3F,0x44,0x40,0x20,0x00},   // t 84
{0x3C,0x40,0x40,0x20,0x7C,0x00},   // u 85
{0x1C,0x20,0x40,0x20,0x1C,0x00},   // v 86
{0x3C,0x40,0x30,0x40,0x3C,0x00},   // w 87
{0x44,0x28,0x10,0x28,0x44,0x00},   // x 88
{0x0C,0x50,0x50,0x50,0x3C,0x00},   // y 89
{0x44,0x64,0x54,0x4C,0x44,0x00}};  // z 90 



void main(void)//主程序
{
uint t,a; 
 uchar k; 
uchar e;
	uchar x;
	uchar y;
  res=0;res=0;res=0; 
  res=1;
  sce=1; 
  sdin=1;
  sclk=1;
  write_byte(0x21,0);//初始化Lcd,功能设定使用扩充指令
  write_byte(0xd3,0);//设定液晶偏置电压(高--低)
  write_byte(0x20,0);//使用基本指令
  write_byte(0x0C,0);//设定显示模式,正常显示
  do
   {
	qp();//清屏
  	for(t=0;t<60000;t++);//延时
  	for(t=0;t<60000;t++);//延时
  	for(t=0;t<60000;t++);//延时
  	for(t=0;t<60000;t++);//延时
      k=0;t=0;		
	  for(x=0;x<91;x++)
	    {    		 
     	for(y=0;y<6;y++)
	     { 
		  e=dal1[x][y];    
	      setadd(k,t);//写地址		
    	  write_byte(e,1);//写数据	     
		k=k+1;    	  
		if(k>83)t=t+1;
		if(k>83)k=0;
		if(t>6)t=0;
	      }  
       for(a=0;a<5000;a++);//延时
       } 
      for(t=0;t<60000;t++);//延时
      for(t=0;t<60000;t++);//延时
      for(t=0;t<60000;t++);//延时
      for(t=0;t<60000;t++);//延时
		setadd(0,0);
      xp();//写一屏图
	  for(t=0;t<60000;t++);//延时
	  for(t=0;t<60000;t++);//延时
	  for(t=0;t<60000;t++);//延时
	  for(t=0;t<60000;t++);//延时
    } 
    while(1);  
}

⌨️ 快捷键说明

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