2019-07-21 08:17发布
lqyfxljb 发表于 2018-11-1 17:52 #include #define WR wr
lqyfxljb 发表于 2018-11-2 16:52 看看你的硬件是否正确,VLCD电压是否正确
最多设置5个标签!
#define WR wr
#define DATA a0
#define CS cs
#define SEG_SIZE (11)
#define COM_SIZE (4)
#define COLUMN_SIZE ((SEG_SIZE >> 1) | (SEG_SIZE & 0x01))
typedef enum
{
SYS_DIS,
SYS_EN,
LCD_OFF,
LCD_ON,
TIMER_DIS,
WDT_DIS,
TIMER_EN,
WDT_EN,
TONE_OFF,
TONE_ON,
CLR_TIMER = 0x0C,
CLR_WDT = 0x0E,
XTAL_32K = 0x14,
RC_256K = 0x18,
EXT_256K = 0x1C,
BIAS1_2DUTY2 = 0x20,
BIAS1_2DUTY3 = 0X24,
BIAS1_2DUTY4 = 0X28,
BIAS1_3DUTY2 = 0X21,
BIAS1_3DUTY3 = 0X25,
BIAS1_3DUTY4 = 0X29,
TONE_4K = 0X40,
TONE_2K = 0X60,
IRQ_DIS = 0X80,
IRQ_EN = 0X88,
F1 = 0XA0,
F2,
F4,
F8,
F16,
F32,
F64,
F128,
NORMAL = 0XE3,
}HT16xx_Command;
typedef enum
{
Command = 0x04,
Data,
Read,
}HT16xx_CommandMode;
void Write_Mode(HT16xx_CommandMode mode)
{
u8 i;
for (i = 0; i < 3; i++)
{
WR = 0;
DATA = (mode >> (2 - i)) & 0x01;
WR = 1;
}
}
void Write_Cmd(HT16xx_Command cmd)
{
u8 i;
for(i=0;i<8;i++)
{
WR = 0;
DATA = (cmd >> (7-i)) & 0x01;
WR = 1;
}
WR = 0;
DATA = 0;
WR = 1;
}
void Write_Addr(u8 Abyte)
{
u8 i;
for(i=0;i<6;i++)
{
WR = 0;NOP;NOP;NOP;
DATA = (Abyte>>(5-i)) & 0x01;
WR = 1;NOP;NOP;NOP;
}
}
void Write_Dat(u8 Dbyte)
{
u8 i;
for(i=0;i<8;i++)
{
WR = 0;NOP;NOP;NOP;
DATA = (Dbyte>>(7-i)) & 0x01;
WR = 1;NOP;NOP;NOP;
}
}
void LcdInit(void)
{
CS = 0;
Write_Mode(Command); //command mode
Write_Cmd(SYS_EN); //Enable System
Write_Cmd(LCD_ON); //Enable Bias
Write_Cmd(TIMER_DIS); //Disable Timer
Write_Cmd(WDT_DIS); //Disable WDT
Write_Cmd(TONE_OFF); //Tone OFF
Write_Cmd(RC_256K); //on-chip RCÕeμ′
Write_Cmd(BIAS1_3DUTY4); //1/4Duty 1/3Bias
Write_Cmd(IRQ_DIS); //Disable IRQ
Write_Cmd(TONE_4K); //Tone Frequency 4kHZ
Write_Cmd(NORMAL); //Normal Mode
CS = 1;
}
void Display_COM(u8 com)
{
u8 i;
CS = 0;
Write_Mode(Data);
Write_Addr(0x00);
for(i = 0; i < COLUMN_SIZE; i++)
{
Write_Dat((0x80 >> com) | (0x08 >> com));
}
CS = 1;
}
void Display_SEG(u8 seg)
{
CS = 0;
Write_Mode(Data);
Write_Addr(seg);
Write_Dat(0xF0);
CS = 1;
}
void Display_Dot(u8 seg, u8 com)
{
CS = 0;
Write_Mode(Data);
Write_Addr(seg);
Write_Dat(0x80 >> com);
CS = 0;
}
void FullRAM(u8 value)
{
u8 i;
CS = 0;
Write_Mode(Data);
Write_Addr(0);
for(i=0;i<16;i++)
Write_Dat(value);
CS = 1;
}
void HT16xx_Test(void)
{
u8 i,j;
for(i = 0; i < COM_SIZE; i++)
{
FullRAM(0x00);
Display_COM(i);
}
for(j = 0; j < SEG_SIZE; j++)
{
FullRAM(0x00);
Display_SEG(j);
}
for(i = 0; i < COM_SIZE; i++)
{
for(j = 0; j < SEG_SIZE; j++)
{
FullRAM(0x00);
Display_Dot(j,i);
}
}
}
void main(void)
{
flash(100);
datal = 0xFF;
dir=1 ;
coe=0 ;
doe=1 ;
koe=1 ;
LcdInit();
FullRAM(0x00);
while(1)
{
HT16xx_Test();
}
}
非常感谢
和我自己驱动的一样,屏幕显示蓝 {MOD},没有其他显示..
现在是有显示了,但是显示不完整
全部显示出来会少几个断码部分
更改延时的大小会增减显示的多少,但怎么改都会有一部分不显示
一周热门 更多>