typedef bit Bit; typedef bit Bool; typedef unsigned char Byte; typedef unsigned int Word; typedef unsigned long Dword;
#define LCDSDA_PIN P1_1 #define LCDSCK_PIN P1_6 #define LCDCS_PIN P3_2
//初始化IO 3根線全部輸出高電平 程序略
下面是4COM 12SEG驅動程序,刷數據前對SEG[0~5]賦值,然后調用Driver_RefreshHT1621函數即可
/*----------------------------------------------------------------------------------------- * * LCD driver HT1621 * ---------------------------- * *----------------------------------------------------------------------------------------*/ #define ID 3 #define COMMAND 9 #define ADDR 6 #define DATA 4 void WriteHT1621(Byte bitLen,Byte value) { Byte i; for(i=bitLen;i>0;i--) { LCDSCK_PIN = 0; value = value<<1; LCDSDA_PIN = CY; _nop_(); _nop_(); LCDSCK_PIN = 1; } } void Driver_RefreshHT1621(void) { Byte i; LCDCS_PIN = 0; WriteHT1621(ID,Bin(10000000)); //command operation WriteHT1621(COMMAND,Bin(00011000)); // -- RC256K WriteHT1621(COMMAND,Bin(00000001)); // -- Turn on OSC WriteHT1621(COMMAND,Bin(00101001)); // -- 1/3Bias 1/4Duty WriteHT1621(COMMAND,Bin(00000011)); // -- Turn On LCD LCDCS_PIN = 1; _nop_(); _nop_(); _nop_(); _nop_(); LCDCS_PIN = 0; WriteHT1621(ID,Bin(10100000)); //data operation WriteHT1621(ADDR,Bin(00000000)); // -- Address for(i=0;i<6;i++) { WriteHT1621(DATA,SEG); // -- SEG00 ~11 WriteHT1621(DATA,(SEG<<4)); } LCDCS_PIN = 1; } |