member_tdh
Member level 5
delay_us 16f88 __asm
Please help me!
PIC -> CD4094 (8-bits) -> LCD = not run!
#include "lcd.h"
//------------------------------------- LCD functions ------------------------------------
void LcdWriteCmd(BYTE cmd)
{
rb1=0; //RW = 0;
rb3=0; //RS=0
rb0=1; //E=1
out_lcd(cmd);
#asm nop #endasm
#asm nop #endasm
#asm nop #endasm
#asm nop #endasm
rb0=0; //E=0
}
void LcdWriteChar(BYTE data)
{
rb1=0; //RW = 0;
rb3=1; //RS=1
rb0=1; //E=1
out_lcd(data);
#asm nop #endasm
#asm nop #endasm
#asm nop #endasm
#asm nop #endasm
rb0=0; //E=0
rb3=0; //RS=0
}
void LcdWriteString(unsigned char *str)
{
// rb3=1; //RS=1
while(*str!= '\0')
{
LcdWriteChar(*str);
++str;
}
}
void LcdGoto(unsigned char row, unsigned char pos)
{
rb3=0; //RS=0 to write command
if(row==1) LcdWriteCmd(LCD_LINE_1 + pos);
else if(row==2) LcdWriteCmd(LCD_LINE_2 + pos);
else if(row==3) LcdWriteCmd(LCD_LINE_3 + pos);
else if(row==4) LcdWriteCmd(LCD_LINE_4 + pos);
rb3=1; //RS=1 to write data
}
void LcdClearRow(unsigned char row)
{
BYTE i;
LcdGoto(row,0);
for(i=0;i<20;i++) LcdWriteChar(' ');
}
void LcdClear(void)
{
rb3=0; //RS=0 to write command
LcdWriteCmd(LCD_CMD_CLEAR); //clear display
delay_us(2);
LcdWriteCmd(LCD_CMD_HOME); //home display
delay_us(2);
rb3=1; //RS=1 to write data
}
void LcdInit(void)
{
delay_us(15000);
rb1=0; //RW = 0;
rb3=0; //RS=0
rb0=0; //E=0
LcdWriteCmd(0x30);
delay_us(40);
LcdWriteCmd(0x30);
delay_us(40);
LcdWriteCmd(0x30);
delay_us(1000);
LcdWriteCmd(0x38); //function set interface length: 8 bit mode, 2lines , 5x7 font
//LcdWriteCmd(0x2C);
delay_us(40);
LcdWriteCmd(0x08); //display off, cursor off, blink off
delay_us(40);
LcdWriteCmd(0x0C); //display on, Cursor on, blink on
delay_us(40);
LcdWriteCmd(0x06); //entry mode set, cursor move right, no shift
delay_us(40);
LcdWriteCmd(0x01); //display clear
delay_us(2000);
}
void out_lcd(BYTE x)
{
BYTE i;
ra4=0;
ra3=0;
for(i=0;i<8;i++)
{
ra3=0;
if(x&0x80) ra4=1;
else ra4=0;
#asm nop #endasm
ra3=1;
#asm nop #endasm
x<<=1;
}
}
Please help me!
PIC -> CD4094 (8-bits) -> LCD = not run!
#include "lcd.h"
//------------------------------------- LCD functions ------------------------------------
void LcdWriteCmd(BYTE cmd)
{
rb1=0; //RW = 0;
rb3=0; //RS=0
rb0=1; //E=1
out_lcd(cmd);
#asm nop #endasm
#asm nop #endasm
#asm nop #endasm
#asm nop #endasm
rb0=0; //E=0
}
void LcdWriteChar(BYTE data)
{
rb1=0; //RW = 0;
rb3=1; //RS=1
rb0=1; //E=1
out_lcd(data);
#asm nop #endasm
#asm nop #endasm
#asm nop #endasm
#asm nop #endasm
rb0=0; //E=0
rb3=0; //RS=0
}
void LcdWriteString(unsigned char *str)
{
// rb3=1; //RS=1
while(*str!= '\0')
{
LcdWriteChar(*str);
++str;
}
}
void LcdGoto(unsigned char row, unsigned char pos)
{
rb3=0; //RS=0 to write command
if(row==1) LcdWriteCmd(LCD_LINE_1 + pos);
else if(row==2) LcdWriteCmd(LCD_LINE_2 + pos);
else if(row==3) LcdWriteCmd(LCD_LINE_3 + pos);
else if(row==4) LcdWriteCmd(LCD_LINE_4 + pos);
rb3=1; //RS=1 to write data
}
void LcdClearRow(unsigned char row)
{
BYTE i;
LcdGoto(row,0);
for(i=0;i<20;i++) LcdWriteChar(' ');
}
void LcdClear(void)
{
rb3=0; //RS=0 to write command
LcdWriteCmd(LCD_CMD_CLEAR); //clear display
delay_us(2);
LcdWriteCmd(LCD_CMD_HOME); //home display
delay_us(2);
rb3=1; //RS=1 to write data
}
void LcdInit(void)
{
delay_us(15000);
rb1=0; //RW = 0;
rb3=0; //RS=0
rb0=0; //E=0
LcdWriteCmd(0x30);
delay_us(40);
LcdWriteCmd(0x30);
delay_us(40);
LcdWriteCmd(0x30);
delay_us(1000);
LcdWriteCmd(0x38); //function set interface length: 8 bit mode, 2lines , 5x7 font
//LcdWriteCmd(0x2C);
delay_us(40);
LcdWriteCmd(0x08); //display off, cursor off, blink off
delay_us(40);
LcdWriteCmd(0x0C); //display on, Cursor on, blink on
delay_us(40);
LcdWriteCmd(0x06); //entry mode set, cursor move right, no shift
delay_us(40);
LcdWriteCmd(0x01); //display clear
delay_us(2000);
}
void out_lcd(BYTE x)
{
BYTE i;
ra4=0;
ra3=0;
for(i=0;i<8;i++)
{
ra3=0;
if(x&0x80) ra4=1;
else ra4=0;
#asm nop #endasm
ra3=1;
#asm nop #endasm
x<<=1;
}
}