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

📄 9864b.c

📁 基于三星S6B0724驱动的PIC点阵液晶98*98点阵程序
💻 C
字号:
#include <pic.h>
#define portat(address,bits) ((unsigned)(&address)*8+(bits))
#define portdata PORTD
#define lcd_time 0xff

static volatile bit RS @ portat(PORTC,0);
static volatile bit RW @ portat(PORTC,1);
static volatile bit E @ portat(PORTC,2);
static volatile bit RST @ portat(PORTC,3);
unsigned char PAGE;
unsigned char x_line;
unsigned char y_line;

const unsigned char  hz_z[16]={0x08,0x10,0x10,0x10,0x13,0x1C,0x10,0x00,0x04,0x1C,0x64,0x84,0x04,0x04,0x18,0x00};
const unsigned char  sz_h[16]={0x10,0x1F,0x10,0x00,0x00,0x10,0x1F,0x10,0x04,0xFC,0x84,0x80,0x80,0x84,0xFC,0x04};
const unsigned char hz_dian[16]={0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0C,0x0C,0x00,0x00,0x00,0x00,0x00};
const unsigned char hz_hengxian[16]={0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x80,0x80,0x80,0x80,0x80,0x80};
const unsigned char hz_hong[32]={0x00,0x08,0x86,0x60,0x07,0x00,0x08,0x08,0xFF,0x88,0x08,0x08,0xFF,0x88,0x18,0x00,
0x00,0x10,0x1E,0xE0,0x00,0x42,0x44,0x58,0xD0,0x40,0x40,0x40,0xD0,0x48,0xC6,0x40};
const unsigned char hz_wen[32]={0x00,0x10,0x10,0x10,0x10,0x1E,0x11,0x10,0xF0,0x90,0x11,0x1E,0x10,0x10,0x30,0x10,
0x00,0x02,0x02,0x04,0x04,0x08,0x88,0x50,0x20,0x50,0x88,0x08,0x04,0x04,0x02,0x02};
const unsigned char hz_bai[32]={0x00,0x10,0x13,0xFF,0x92,0x31,0x00,0x00,0x1F,0x10,0x30,0xD0,0x90,0x10,0x3F,0x10,
0x00,0x60,0x80,0xFE,0x00,0x80,0x00,0x00,0xFE,0x84,0x84,0x84,0x84,0x84,0xFE,0x00};
const unsigned char hz_she[32]={0x04,0x04,0x84,0x67,0x02,0x04,0x7A,0x43,0x42,0x42,0xF2,0x4B,0x08,0x08,0x00,0x00,
0x00,0x00,0xF0,0x24,0x44,0x08,0x88,0x50,0x20,0x50,0x88,0x0C,0x08,0x00};
const unsigned char hz_ji[32]={0x04,0x84,0x44,0x67,0x00,0x04,0x04,0x04,0x04,0xFF,0x04,0x04,0x0C,0x04,0x00,0x00,
0x00,0x00,0xF8,0x10,0x20,0x00,0x00,0x00,0xFC,0x00,0x00,0x00,0x00,0x00};
const unsigned char sz_f[16]={0x10,0x1F,0x11,0x11,0x17,0x10,0x08,0x00,0x04,0xFC,0x04,0x00,0xC0,0x00,0x00,0x00};
const unsigned char sz_m[16]={0x10,0x1F,0x1F,0x00,0x1F,0x1F,0x10,0x00,0x04,0xFC,0x00,0xFC,0x00,0xFC,0x04,0x00};
const unsigned char sz_number[160]={0x00,0x07,0x08,0x10,0x10,0x08,0x07,0x00,0x00,0xF0,0x08,0x04,0x04,0x08,0xF0,
0x00,0x00,0x08,0x08,0x1F,0x00,0x00,0x00,0x00,0x00,0x04,0x04,0xFC,0x04,0x04,0x00,0x00,0x00,0x0E,0x10,0x10,0x10,
0x11,0x0E,0x00,0x00,0x0C,0x14,0x24,0x44,0x84,0x0C,0x00,0x00,0x0C,0x10,0x11,0x11,0x12,0x0C,0x00,0x00,0x18,0x04,
0x04,0x04,0x88,0x70,0x00,0x00,0x00,0x03,0x04,0x08,0x1F,0x00,0x00,0x00,0xE0,0x20,0x24,0x24,0xFC,0x24,0x00,
0x00,0x1F,0x10,0x11,0x11,0x10,0x10,0x00,0x00,0x98,0x84,0x04,0x04,0x88,0x70,0x00,0x00,0x07,0x08,0x11,0x11,0x18,
0x00,0x00,0x00,0xF0,0x88,0x04,0x04,0x88,0x70,0x00,0x00,0x1C,0x10,0x10,0x13,0x1C,0x10,0x00,0x00,0x00,0x00,0xFC,
0x00,0x00,0x00,0x00,0x00,0x0E,0x11,0x10,0x10,0x11,0x0E,0x00,0x00,0x38,0x44,0x84,0x84,0x44,0x38,0x00,0x00,0x07,
0x08,0x10,0x10,0x08,0x07,0x00,0x00,0x00,0x8C,0x44,0x44,0x88,0xF0,0x00};
const unsigned char sz_r[16]={0x10,0x1F,0x11,0x11,0x11,0x11,0x0E,0x00,0x04,0xFC,0x04,0x00,0xC0,0x30,0x0C,0x04};
const unsigned char sz_a[16]={0x00,0x00,0x01,0x01,0x01,0x01,0x00,0x00,0x00,0x98,0x24,0x44,0x44,0x44,0xFC,0x04};
const unsigned char sz_d[16]={0x00,0x00,0x00,0x01,0x01,0x11,0x1F,0x00,0x00,0x70,0x88,0x04,0x04,0x08,0xFC,0x04};
const unsigned char sz_i[16]={0x00,0x01,0x19,0x19,0x00,0x00,0x00,0x00,0x00,0x04,0x04,0xFC,0x04,0x04,0x00,0x00};
const unsigned char sz_o[16]={0x00,0x00,0x01,0x01,0x01,0x01,0x00,0x00,0x00,0xF8,0x04,0x04,0x04,0x04,0xF8,0x00};
const unsigned char sz_c[16]={0x03,0x0C,0x10,0x10,0x10,0x10,0x1C,0x00,0xE0,0x18,0x04,0x04,0x04,0x08,0x10,0x00};
const unsigned char sz_l[16]={0x00,0x10,0x10,0x1F,0x00,0x00,0x00,0x00,0x00,0x04,0x04,0xFC,0x04,0x04,0x00,0x00};
const unsigned char sz_s[16]={0x00,0x00,0x01,0x01,0x01,0x01,0x01,0x00,0x00,0xCC,0x24,0x24,0x24,0x24,0x98,0x00};
const unsigned char sz_e[16]={0x00,0x00,0x01,0x01,0x01,0x01,0x00,0x00,0x00,0xF8,0x44,0x44,0x44,0x44,0xC8,0x00};

void system_inti(void)
 {
  INTCON = 0x00;
  TRISC = 0xf0;
  TRISD = 0x00;
  di();
  }

void lcd_delay(unsigned int number)
 {
  unsigned int i;

   for (i=0;i<number;i++)
    {
     }
 }

void lcd_rst(void)
 {
   RST = 0;
   lcd_delay(lcd_time);
   RST = 1;
   lcd_delay(lcd_time);
  }

void lcd_busy(void)
 {
  unsigned char temp;

  portdata = 0xff;
  RS = 0;
  RW = 1;
  E=1;
  TRISD = 0xff;
  temp = portdata;
  E = 0;
  while (temp & 0x80);
  TRISD = 0x00;
  return;
  }

void write_command(unsigned char send_command)
 {
  lcd_busy();
  RS = 0;
  RW = 0;
  portdata = send_command;
  E = 1;
  E = 0;
  }

void write_data(unsigned char send_data)
 {
  lcd_busy();
  write_command(x_line);
  write_command(y_line);
  RS = 1;
  RW = 0;
  portdata = send_data;
  E = 1;
  E = 0;
  y_line ++;
  if ((y_line & 0x0f) == 0x00)
   {
    x_line++;
    y_line = 0x00;
    }
  }

void lcd_init(void)
 {
  system_inti();
  lcd_rst();
  write_command(0xe2);
  write_command(0xa2);
  write_command(0xa0);
  write_command(0xc0);
  write_command(0x2f);
  write_command(0x81);
  write_command(0x2f);
  write_command(0x40);
  write_command(0xe0);
  write_command(0xaf);
  }
void lcd_clear(void)
 {
    unsigned char i,j;
    
    PAGE = 0xb0;
    x_line = 0x10;
    y_line = 0x00;
    for(i = 0;i<8;i++)
    {   
       write_command(PAGE);
        for(j=0;j<98;j++)
        {
          write_data(0x05);
	    }
       PAGE++; 
     }
 }

void main(void)
 {
  lcd_delay(10000);
  lcd_init();
  write_command(0x40); 
  lcd_clear();
  while (1)
  {
   }
  }

⌨️ 快捷键说明

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