📄 hallcdssd1818.c
字号:
//*******************************************************************************
// E5-Inc Pte. Ltd. - 2008 - All right reserved
//*******************************************************************************
//
// Project :
// Type :
// Name :
// Instance :
// Created by :
// Creation date:
// Description :
//
//*******************************************************************************
//
//*******************************************************************************
// HISTORICAL
//*******************************************************************************
//
// Date :
// Changed by :
// Description :
//
//*******************************************************************************
//######################################
// halLcdSSD1818.c
//######################################
// Function1:
// Function2:
// Function3:
// --- Main.c ----
// --- End -------
// =====================================
// lcdSSD1818 | Delay2Us for Pulse stable
// -------------------------------------
// SeeAs SSD1818Datasheet.pdf Page38, RaseTime=15ns, FallTime=15ns, CycleTime=300ns
// =====================================
//#define lcdDelay() __NOP(); __NOP();
// =====================================
// Lcd | BasicFunction | SendLcdCommand | no Stack
// -------------------------------------
// e.g. __lcdSendCommand(0xAf); //Display On
// =====================================
void lcdSendCommand()
{
_LcdDCoff(); //command mode
_LcdCSoff(); //chip select
_LcdWRoff(); //ready to write
_LcdData = lcdbus; //cmd; //write the byte
_LcdWRon(); //write complete
_LcdCSon(); //chips de-select
_LcdDCon(); //back to data mode
}
#define __lcdSendCommand(U8LcdCmd) lcdbus=U8LcdCmd; lcdSendCommand();
// =====================================
// Lcd | BasicFunction | SendLcdData | no Stack
// -------------------------------------
// e.g. __lcdSendData(0x20); //Write lcd data
// =====================================
void lcdSendData()
{
_LcdDCon(); //data mode
_LcdCSoff(); //chip select
_LcdWRoff(); //ready to write
_LcdData = lcdbus; //busdata; //write the byte
_LcdWRon(); //write complete
_LcdCSon(); //chips de-select
}
#define __lcdSendData(U8LcdData) lcdbus=U8LcdData; lcdSendData();
// =====================================
// lcdSSD1818 | Initial | 2008Aug12
// =====================================
//(1)Reset Circuit (0xE2)
//This block includes Power On Reset (POR) circuitry and the hardware reset pin, RES . The POR and
//Hardware reset performs the same reset function. Once RES receives a reset pulse, all internal circuitry
//will start to initialize. Minimum pulse width the reset sequence is 5 - 10us. Status of the chip after reset is
//given by:
//(2)Display is turned OFF (0xAE)
//(3)Default Display Mode: 104 x 64 + 1 Icon Line
// 48 MUX Mode: 104 x 48 + 1 Icon Line
// 54 MUX Mode: 104 x 54 + 1 Icon Line
// 32 MUX Mode: 104 x 32 + 1 Icon Line
// *64 MUX Mode: 104 x 64 + 1 Icon Line
//(4)Normal segment and display data column address mapping (Seg0 mapped to Row address 00h)
//??(5)Read-modify-write mode is OFF
//(6)Power control register is set to 000b
//(7)Shift register data clear in serial interface
//(8)Bias ratio is set to default: 1/9
// 48 MUX Mode: 1/8
// 54 MUX Mode: 1/8.4
// 32 MUX Mode: 1/6
// *64 MUX Mode: 1/9
//(9)Static indicator is turned OFF
//(10)Display start line is set to GDDRAM column 0
//(11)Column address counter is set to 00h
//(12)Page address is set to 0
//(13)Normal scan direction of the COM outputs
//(14)Contrast control register is set to 20h
//(15)Test mode is turned OFF
//(16)Temperature Coefficient is set to TC0
//Note: Please find more explanation in the Applications Note attached at the back of the specification.
// =====================================
//
// =====================================
void initLcdSsd1818(void)
{
//(1) Trigger Lcd Reset Pin
_LcdRESoff();
__NOP();__NOP();__NOP();__NOP();__NOP();
__NOP();__NOP();__NOP();__NOP();__NOP();
_LcdRESon();//Lcd reset
__NOP();__NOP();__NOP();__NOP();__NOP();
//(2)Sent Initial Lcd Command
__lcdSendCommand(0xe2); //(A)Software reset
__NOP();__NOP();__NOP();__NOP();__NOP();
__lcdSendCommand(0xA2); //(B)Bias 1/9
__NOP();__NOP();
// lcdSendCommand(0x2C); //(C)VC ON, VR OFF, VF OFF >>Output OpAmp
// __NOP();__NOP();
// lcdSendCommand(0x2E); //(D)VC ON, VR ON, VF OFF >>Internal Regulator
// __NOP();__NOP();
__lcdSendCommand(0x2F); //(E)VC ON, VR ON, VF ON >>Internal Voltage Booster
__NOP();__NOP();
__lcdSendCommand(0x23); //(F)SET INTERNAL RESISTOR GAIN 0x20 to 0x27
__NOP();__NOP();
//-->
__lcdSendCommand(0x81); //(G)SET CONTRAST command 0x81
__NOP();__NOP();
__lcdSendCommand(0x35); ////3C 3D=15 ohm, 15=3F ohm, Coefficient 3D=15 (DEFAULT=0x37) 30h(Light)-38h(Dark)
__NOP();__NOP();
//-->
__lcdSendCommand(0xA9); //(H)SET BIAS RATIO, TC, OSC
__NOP();__NOP();
__lcdSendCommand(0x48); //SET BIAS RATIO, TC, OSC 68// 1/9, -0.13%, DEFAULT FREQ=21.7KHZ
__NOP();__NOP();
//-->
__lcdSendCommand(0xA8); //(I)1ST SET MULTIPLEX RATIO
__NOP();__NOP();
__lcdSendCommand(0x3f); //2ND SET MULTIPLEX RATIO 64MUX not sure???
__NOP();__NOP();
//-->feedback from philips supplier
// lcdSendCommand(0xD6); //(J)(D6)ENABLE BAND-GAP
// __NOP();__NOP();
// lcdSendCommand(0x3F); //(3F)ENABLE BAND-GAP = 800 ms
// __NOP();__NOP();
//-->
__lcdSendCommand(0xD4); //(K)SET TOTAL FRAME PHASES
__NOP();__NOP();
__lcdSendCommand(0x30); //9 PHASES = 20, 16 PHASES = 10
__NOP();__NOP();
//-->
__lcdSendCommand(0xD0); //(L)ICON OFF, IconOff
__NOP();__NOP();
__lcdSendCommand(0xAA); //(M)SET 1/4 BIAS RATIO, USE NORMAL SETTING AA
__NOP();__NOP();
//-- Orginal -->
__lcdSendCommand(0xA0); //(O)SET COLUMN ADDRESS IS MAP SEG0
__NOP();__NOP();
__lcdSendCommand(0xC8); //(P)SET ROW ADDRESS IS MAP COM0 REMAPPED
__NOP();__NOP();
__lcdSendCommand(0xA4); //(Q)SET ENTIRE DISPLAY ON/OFF=NORMAL DISPLAY
__NOP();__NOP();
__lcdSendCommand(0xA6); //(R)SET NORMAL(A6)/REVERSE(A7) DISPLAY
__NOP();__NOP();
__lcdSendCommand(0x40); //INITIAL DISPLAY LINE
__NOP();__NOP();
}
// =====================================
// Lcd | Function | WriteChar | oneStack
// -------------------------------------
// e.g. __lcdWriteChar('A');
// =====================================
void lcdWriteChar()
{
lcdT.tiun[0].value = (lcdchar.value-0x20)*8;
lcdT.tcun[2].value=8;
do{
__lcdSendData(lcdFontMap8x8[lcdT.tiun[0].value]); lcdT.tiun[0].value++;
}while(--lcdT.tcun[2].value);
}
#define __lcdWriteChar(U8LcdChar) lcdchar.value=U8LcdChar; lcdWriteChar();
// =====================================
// Lcd | Function | WriteNumber | twoStack: (1)current(2)lcdSentData
// -------------------------------------
// lcdT[0]:TableAddr; lcdT[1]: counter
// -------------------------------------
// e.g. __lcdWriteNum(3); //Display "3"
// =====================================
void lcdWriteNumber()
{
lcdT.tcun[0].value = lcdchar.value *8;
lcdT.tcun[1].value=8;
do{
__lcdSendData(lcdMapNum[lcdT.tcun[0].value]); lcdT.tcun[0].value++;
}while(--lcdT.tcun[1].value);
}
#define __lcdWriteNum(U8LcdNum) lcdchar.value=U8LcdNum; lcdWriteNumber();
// =====================================
// Lcd | Function | WriteChar | twoStack
// -------------------------------------
// lcdT[0]:TableAddr; lcdT[1]: counter
// -------------------------------------
//
// =====================================
void lcdWriteSChar()
{
lcdT.tcun[0].value = lcdchar.value *__constFontColumn;
lcdT.tcun[1].value=__constFontColumn;
do{
__lcdSendData(lcdMapChar[lcdT.tcun[0].value]); lcdT.tcun[0].value++;
}while(--lcdT.tcun[1].value);
}
#define __lcdWriteSChar(U8LcdChar) lcdchar.value=U8LcdChar; lcdWriteSChar();
// =====================================
// Lcd | Function | WriteUpperAlpha | twoStack:(1)current(2)lcdSendData
// -------------------------------------
// lcdT[0]:TableAddr; lcdT[2]: counter
// -------------------------------------
//
// =====================================
void lcdWriteUpperAlpha()
{
lcdT.tcun[0].value = lcdchar.value *8;
lcdT.tcun[2].value=8;
do{
__lcdSendData(lcdMapUpperAlpha[lcdT.tcun[0].value]); lcdT.tcun[0].value++;
}while(--lcdT.tcun[2].value);
}
#define __lcdWriteUpperAlpha(U8LcdUAlpha) lcdchar.value=U8LcdUAlpha; lcdWriteUpperAlpha();
// =====================================
// Lcd | Function | WriteLowerAlpha | twoStack:(1)current(2)lcdSendData
// -------------------------------------
// lcdT[0]:TableAddr; lcdT[1]: counter
// -------------------------------------
//
// =====================================
void lcdWriteLowerAlpha()
{
lcdT.tcun[0].value = lcdchar.value *8;
lcdT.tcun[1].value=8;
do{
__lcdSendData(lcdMapLowerAlpha[lcdT.tcun[0].value]); lcdT.tcun[0].value++;
}while(--lcdT.tcun[1].value);
}
#define __lcdWriteLowerAlpha(U8LcdLAlpha) lcdchar.value=U8LcdLAlpha; lcdWriteLowerAlpha();
// =====================================
// Lcd | Function | set x,y Positioin| oneStack
// -------------------------------------
// __lcdWriteLocation(0b111, 0111,1); //Page,HiCol,LoCol
// -------------------------------------
//e.g. __lcdWriteLocation(0b001 00001); //1Row, 2Font
// =====================================
void lcdWriteLocation()
{
//(1)Row
lcdT.tcun[2].value=lcdT.tcun[0].value&0b11100000;
lcdT.tcun[2].value>>=4;
lcdT.tcun[2].value>>=1;
lcdT.tcun[2].value|=0xB0;
//(2)Column
lcdT.tcun[1].value=(lcdT.tcun[0].value<<=3);
lcdT.tcun[1].value>>=4;
lcdT.tcun[1].value|=0x10;
lcdT.tcun[0].value&=0x0F;
__lcdSendCommand(lcdT.tcun[2].value); //PAGE
__lcdSendCommand(lcdT.tcun[1].value); //SET HIGHER COL ADDR
__lcdSendCommand(lcdT.tcun[0].value); //SET LOWER COL ADDR
}
#define __lcdWriteLocation(U8Location) lcdT.tcun[0].value=U8Location; lcdWriteLocation();
/* End of Ebt.c */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -