#include"sfr_r82b.h" #define uchar unsigned char #define uint unsigned int #define Data_HT1622 p1_addr.bit.b0 #define WR_HT1622 p0_addr.bit.b0 #define CS_HT1622 p0_addr.bit.b1 #define beiguang1622 p6_addr.bit.b0 //HT1622初始化
void Delay_us(uchar a) { uchar z; for(z=a;z>0;z--); }
//HT1622写入脉冲 void LCD_CLK(void) { Delay_us(10); WR_HT1622 = 0; Delay_us(10); WR_HT1622 = 1; Delay_us(10); } //向HT1622写命令 void LCD_WRCMD(uint dat) { uchar i; CS_HT1622 = 0; Delay_us(3); for (i=0;i<12;i++) { if (dat&0x8000==0x800) { Data_HT1622 = 1; } else { Data_HT1622 = 0; }
dat <<= 1; LCD_CLK(); } Delay_us(3); CS_HT1622 = 1; } //向HT1622写数据 void LCD_WRDATA(uint date) { uchar j; CS_HT1622 = 0; Delay_us(3); for (j=0;j<13;j++) { if (date&0x8000==0x800) { Data_HT1622 = 1; } else { Data_HT1622 = 0; }
date <<= 1; LCD_CLK(); } Delay_us(3); CS_HT1622 = 1; } //初始化 void LCD_Init(void) { pd6_addr.bit.b0=1; pd1_addr.bit.b7=1; pd0_addr.bit.b0=1; pd0_addr.bit.b1=1; pd1_addr.bit.b0=1; LCD_WRCMD(0x8000); LCD_WRCMD(0x8020); LCD_WRCMD(0x8300); LCD_WRCMD(0x8040); LCD_WRCMD(0x8060); LCD_WRCMD(0x0000); } void main() { LCD_Init(); beiguang1622=1; if(p1_addr.bit.b7==1) { Delay_us(3); if(p1_addr.bit.b7==1) { LCD_WRDATA(0xBCF8); } } else { LCD_WRDATA(0xBC80); } }
|