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

📄 lm9864a.c

📁 基于三星S6B0724驱动的PIC点阵液晶98*98点阵程序
💻 C
字号:
#include <pic.h> 
#include <stdlib.h>
#include <math.h>
#define portat(address,bits) ((unsigned)(&address)*8+(bits)) 
#define portdata PORTD 
#define lcd_time 0xff 
#define lcd_shorttime 0x02 
#define write_com 0x00 
#define write_data 0xff 
#define page 0xb0 
#define x_line 0x01 
#define y_line 0x00 
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); 
void system_inti(void) 
{ 
  INTCON = 0x00; 
  TRISC = 0xf0; 
  TRISD = 0x00; 
  di(); 
  } 
void lcd_delay(unsigned char number) 
{ 
  unsigned char i; 
   for (i=0;i<number;i++) 
    { 
     } 
} 
void lcd_rst(void) 
{ 
   RST = 0; 
   lcd_delay(lcd_time); 
   RST = 1; 
   lcd_delay(lcd_time); 
  } 
unsigned char lcd_read(void) 
{ 
  unsigned char temp; 
  portdata = 0xff; 
  RS = 0; 
  RW = 1; 
  E=1; 
  TRISD = 0xff; 
  temp = portdata; 
  E = 0; 
  TRISD = 0x00; 
  return temp; 
  } 
void command_write(unsigned char flag,unsigned char send_data) 
{ 
  if (flag == write_com) RS = 0; 
  else RS = 1; 
  RW = 0; 
  portdata = send_data; 
  E = 1; 
  E = 0; 
  while (lcd_read() & 0x80);
  } 
void lcd_init(void) 
{ 
  system_inti(); 
  lcd_rst(); 
  command_write(write_com,0xe2); 
  lcd_delay(lcd_shorttime); 
  command_write(write_com,0xa2); 
  lcd_delay(lcd_shorttime); 
  command_write(write_com,0xa0); 
  lcd_delay(lcd_shorttime); 
  command_write(write_com,0xc0); 
  lcd_delay(lcd_shorttime); 
  command_write(write_com,0x2f); 
  lcd_delay(lcd_shorttime); 
  command_write(write_com,0x81); 
  lcd_delay(lcd_shorttime); 
  command_write(write_com,0x2f); 
  lcd_delay(lcd_shorttime); 
  command_write(write_com,0x40); 
  lcd_delay(lcd_shorttime); 
  command_write(write_com,0xe0); 
  lcd_delay(lcd_shorttime); 
  command_write(write_com,0xaf); 
  lcd_delay(lcd_shorttime); 
  } 
void lcd_write_data(unsigned char lcd_data) 
{ 
    unsigned char i,j; 
    for(i = 0;i<8;i++) 
    { 
        command_write(write_com,page|i); 
        command_write(write_com,x_line); 
        command_write(write_com,y_line); 
        for(j=0;j<98;j++) 
        { 
          command_write(write_data,lcd_data); 
  } 
     } 
} 
void main(void) 
{ 
  double a,b;
  unsigned char c,d;

  lcd_init(); 
  lcd_write_data(0x0f);
  a = 0.532;
  b = acos(a);
  c = 0x02;
  d = 0x88;
  eeprom_write(c,d);
  while (1) 
  { 
   } 
  }

⌨️ 快捷键说明

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