• PUDN用户
    了解作者
  • C++
    开发工具
  • 42KB
    文件大小
  • rar
    文件格式
  • 0
    收藏次数
  • 1 积分
    下载积分
  • 26
    下载次数
  • 2009-11-25 13:11
    上传日期
AT89C51SND1 + ST7565P 8x8 LCD Display module
LCD_demo_code.rar
  • LCD_demo_code
  • include
  • global.h
    4B
  • constant.h
    37B
  • typedef.h
    445B
  • macro.h
    96B
  • at89c51snd.h
    7.4KB
  • external.h
    465B
  • config.h
    129B
  • Lcd.plg
    721B
  • lcd_Uv2.Bak
    2KB
  • main.LST
    19.2KB
  • lcd.Uv2
    2.4KB
  • lcd.Opt
    1.3KB
  • Lcd
    22.3KB
  • main.c
    9.2KB
  • Lcd.lnp
    24B
  • lcd_Opt.Bak
    1.2KB
  • Lcd.hex
    7.1KB
  • usb_printf.M51
    19.6KB
  • Lcd.M51
    26.3KB
  • main.c.bak
    9.2KB
  • main.OBJ
    23.8KB
  • test.M51
    10.1KB
内容介绍
#define GLOBAL_H #include "stdio.h" #include "intrins.h" #include "config.h" #include "typedef.h" #include "at89c51snd.h" #include "constant.h" #include "macro.h" #include "external.h" //typedef unsigned char BYTE; // 8bit #define CS2 P5_1 #define LCD_A0 P5_0 #define LCD_SCL P4_7 #define LCD_SI P4_6 #define CS2_LOW {CS2=0;} #define CS2_HIGH {CS2=1;} #define LCD_A0_LOW {LCD_A0=0;} #define LCD_A0_HIGH {LCD_A0=1;} #define LCD_SCL_LOW {LCD_SCL=0;} #define LCD_SCL_HIGH {LCD_SCL=1;} #define LCD_SI_LOW {LCD_SI=0;} #define LCD_SI_HIGH {LCD_SI=1;} #define LCD_DATA 1 #define LCD_COMMAND 0 Byte gContrast=40; // LCD 对比度0-63 Uint8 code display_0[]={ 0x00, 0x1c, 0x22, 0x41, 0x41, 0x22, 0x1c, 0x00 }; Uint8 code display_1[]={ 0x00, 0x00, 0x21, 0x7f, 0x01, 0x00, 0x00, 0x00 }; Uint8 code display_weiching[]={ 0x40,0x7c,0x43,0x1c,0x43,0x7c,0x40,0x00,/*w*/ 0x00,0x1c,0x2a,0x2a,0x2a,0x1a,0x00,0x00, 0x00,0x00,0x00,0xbe,0x00,0x00,0x00,0x00, 0x00,0x1c,0x22,0x22,0x22,0x14,0x00,0x00, 0x00,0x82,0xfe,0x10,0x10,0x0e,0x02,0x00, 0x00,0x00,0x00,0xbe,0x00,0x00,0x00,0x00, 0x00,0x22,0x1e,0x20,0x20,0x1e,0x02,0x00, 0x00,0x32,0x49,0x49,0x49,0x7e,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x41,0x7f,0x21,0x18,0x21,0x7f,0x41,0x00, 0x00,0x41,0x7f,0x45,0x44,0x38,0x00,0x00, 0x00,0x22,0x49,0x49,0x49,0x36,0x00,0x00 }; Uint8 code display_volume[]={ 0x01,0x01,0x00,0x03,0x03,0x00,0x03,0x07, 0x00,0x0f,0x0f,0x00,0x1f,0x1f,0x00,0x3f, 0x3f,0x00,0x7f,0x7f,0x00,0xff,0xff,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x1c,0x22,0x22,0x22,0x22,0x27,0x22,0x00, 0x22,0x72,0x22,0x22,0x22,0x22,0x1c,0x00, 0x3f,0x44,0x3f,0x00,0x7f,0x00,0x7f,0x00, 0x7f,0x48,0x37,0x00,0x0f,0x08,0x07,0x00, 0x06,0x09,0x7f,0x00,0x00,0x00,0x00,0x00 }; Uint8 code display_time_up[]={ 0x00,0x00,0x00,0x00,0x1f,0x10,0x10,0x10, 0x10,0x10,0x10,0x1f,0x00,0x1f,0x10,0x10, 0x10,0x10,0x10,0x10,0x1f,0x00,0x06,0x00, 0x1f,0x10,0x10,0x10,0x10,0x10,0x10,0x1f, 0x00,0x1f,0x10,0x10,0x10,0x10,0x10,0x10, 0x1f,0x00,0x06,0x00,0x1f,0x10,0x10,0x10, 0x10,0x10,0x10,0x1f,0x00,0x10,0x10,0x10, 0x10,0x10,0x10,0x10,0x1f,0x00,0x00,0x00, }; Uint8 code display_time_down[]={ 0x00,0x00,0x00,0x00,0xfc,0x04,0x04,0x04, 0x04,0x04,0x04,0xfc,0x00,0xfc,0x04,0x04, 0x04,0x04,0x04,0x04,0xfc,0x00,0x30,0x00, 0xfc,0x04,0x04,0x04,0x04,0x04,0x04,0xfc, 0x00,0xfc,0x84,0x84,0x84,0x84,0x84,0x84, 0xfc,0x00,0x30,0x00,0xfc,0x04,0x04,0x04, 0x04,0x04,0x04,0xfc,0x00,0xfc,0x84,0x84, 0x84,0x84,0x84,0x84,0x84,0x00,0x00,0x00 }; void LCDInit(void); void LCDWriteByte(char lcddata,Byte command); void LCDShiftWrite(char lcddata); void LCDcls(void); void DelayMS(void); void LCDSetXY(BYTE x, BYTE y); void main(void){ Uint8 i; Enable_interrupt(); /* global enable */ Set_x2_mode(); com_init(); printf("======================================\n"); printf("============LCD Demo Code=============\n"); printf("======================================\n"); printf("LCD init\n"); LCDInit(); while(1){} } void com_init(void) { BDRCON=0X1E; //BRR=1,TBCK=1,RBCK=1,SPD=1 BRL=152; PCON|=0x80; SM0 = 0; SM1 = 1;SM2 = 0; REN = 1; TI = 0; //clear transmit interrupt RI = 0; //clear receiver interrupt ES = 0; //disable serial interrupts SBUF=0; } void DelayBusClock(void) { Uint8 i; for(i=0;i<20;i++); } void nt750xClearLcd(void) { Uint8 i,j; for(i=0;i<8;i++)//clear all page data { nt750xSetPageAddr(i); nt750xSetColumnAddr(0); for(j=0;j<128;j++) { nt750xWriteData(0x00); } } } void nt750xWriteCommand(Uint8 u8Command)//A0=low { Uint8 i; CS2_LOW LCD_A0_LOW for(i=1;i<9;i++) { LCD_SCL_LOW if(u8Command&0x80) LCD_SI_HIGH else LCD_SI_LOW DelayBusClock(); LCD_SCL_HIGH DelayBusClock(); u8Command=u8Command<<1; } LCD_SCL_LOW LCD_A0_LOW CS2_HIGH } void nt750xWriteData(Uint8 ch)//A0=high { Uint8 i; CS2_LOW LCD_A0_LOW for(i=1;i<9;i++) { LCD_SCL_LOW _nop_(); _nop_(); if(ch&0x80) LCD_SI_HIGH else LCD_SI_LOW if(i==8) LCD_A0_HIGH _nop_(); _nop_(); DelayBusClock(); LCD_SCL_HIGH _nop_(); _nop_(); DelayBusClock(); ch=ch<<1; } LCD_SCL_LOW LCD_A0_LOW CS2_HIGH _nop_(); _nop_(); DelayBusClock(); } void nt750xSetStartLine(Uint8 u8StartLine) { Uint8 u8Temp; u8Temp=0x40|(u8StartLine&0x1f); nt750xWriteCommand(u8Temp); } void nt750xSetPageAddr(Uint8 u8PageAddr) { Uint8 u8Temp; u8Temp=0xb0|(u8PageAddr&0x0f); nt750xWriteCommand(u8Temp); } void nt750xSetColumnAddr(Uint8 u8ColumnAddr) { Uint8 u8Temp; u8Temp=0x10|(u8ColumnAddr>>4);//high nibble nt750xWriteCommand(u8Temp); u8Temp=u8ColumnAddr&0x0f;//low nibble nt750xWriteCommand(u8Temp); } void nt750xSetContrast(Uint8 u8Level) { Uint8 u8Temp; #ifdef Select_NT7502 nt750xWriteCommand(0x81); u8Temp=u8Level&0x1f; nt750xWriteCommand(u8Temp); #else u8Temp=0x80|(u8Level&0x1f); nt750xWriteCommand(u8Temp); #endif } void DelayMS(void) { Uint16 i; for(i=0;i<200;i++); } //-------------------------------------------------------------------------- // //-------------------------------------------------------------------------- void LCDInit(void) { UINT32 i; P1_0 = 0; //RST=0; DelayMS(); DelayMS(); DelayMS(); DelayMS(); DelayMS(); DelayMS(); P1_0 = 1; // RST=1; DelayMS(); DelayMS(); DelayMS(); DelayMS(); DelayMS(); DelayMS(); DelayMS(); DelayMS(); printf("write cmd\n"); LCDWriteByte(0xe2,LCD_COMMAND);//lcd reset LCDWriteByte(0x2f,LCD_COMMAND);//display off LCDWriteByte(0x25,LCD_COMMAND);//lcd bias select 1/9 BIAS LCDWriteByte(0x81,LCD_COMMAND);//ADC select,REVERSE 127-->0(a0,a1) LCDWriteByte(0x14,LCD_COMMAND);//com select,NORMAL 0-->63(c8,c0) LCDWriteByte(0xc0,LCD_COMMAND);//RESISTOR RATIO LCDWriteByte(0xa0,LCD_COMMAND);//ELECTRONIC VOLUME mode setting 100B LCDWriteByte(0xaf,LCD_COMMAND);//Set reference voltagel register nt750xClearLcd(); nt750xSetPageAddr(6); nt750xSetColumnAddr(0); for(i=0;i<96;i++) { nt750xWriteData(display_weiching[i]); } nt750xSetPageAddr(4); nt750xSetColumnAddr(16); for(i=0;i<64;i++) { nt750xWriteData(display_time_up[i]); } nt750xSetPageAddr(3); nt750xSetColumnAddr(16); for(i=0;i<64;i++) { nt750xWriteData(display_time_down[i]); } nt750xSetPageAddr(0); nt750xSetColumnAddr(0); for(i=0;i<72;i++) { nt750xWriteData(display_volume[i]); } printf("write cmd end\n"); } //-------------------------------------------------------------------------- // //-------------------------------------------------------------------------- void LCDWriteByte(char lcddata,Byte command) { CS2_LOW//CS=0 DelayBusClock(); if(command == 0) { LCD_A0_LOW //A0=0 DelayBusClock(); LCDShiftWrite(lcddata); } else { LCD_A0_HIGH //A0=1 DelayBusClock(); LCDShiftWrite(lcddata); } CS2_HIGH//CS=1; DelayBusClock(); } //-------------------------------------------------------------------------- // //-------------------------------------------------------------------------- void LCDShiftWrite(char lcddata) { unsigned char i; unsigned char Series,Temp; LCD_SCL_LOW //SCL=0 Series = lcddata; for(i=8;i>0;i--) { LCD_SCL_LOW //SCL=0 DelayBusClock(); Te
评论
    相关推荐