Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

serial LCD (interfacing CD4094) error!

Status
Not open for further replies.

member_tdh

Member level 5
Joined
Feb 6, 2006
Messages
86
Helped
1
Reputation
2
Reaction score
1
Trophy points
1,288
Activity points
2,187
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;
}
}
 

Hi,

1. Where is your Main function to write something to display?

2. Also please show the schematic of how 4094 is connected between PIC and LCD.

Regards,
Laktronics
 

Hi!

trisa4=0; //4094_data
trisa3=0; //4094_clock
ra4=0;
ra3=0;


Main.c Function:

#include "16f88.h"

void main(void)
{
trisb3=0; //lcd_RS
trisb1=0; //lcd_RW
trisb0=0; //lcd_E
rb3=0;rb1=0;rb0=0;

LcdInit();
LcdClear();
LcdGoto(1,0);
LcdWriteChar('A');
//LcdWriteString("ABCDEF");

//error: not display char 'A' or string.

while(1)
{

}

}
 

Hi,
1. In the LCDGoto() function, the value of LCD_Line_X is not specified,I suppose it is specified in the LCD.h file. In that case if values of Line_x is specified as 00h, 40h etc, you need to add 80h to those values as per SET DDRAM ADDRESS command. Please check this and correct if required.

2. In the LCD_INIT routine, under DISPLAY_ON command, you have not turned on the cursor, the command value here should be 0X0E and not 0X0C. I think the cursor is not turned on any where else?

3. The string will not be displayed as it is commented out.

Regards,
Laktronics
 

    member_tdh

    Points: 2
    Helpful Answer Positive Rating
Hi!

In "lcd.h" file: I define Lcd_line as:

#define LCD_LINE_1 0x80 /* bit 7 is always set: 0x80 = 0x00 */
#define LCD_LINE_2 0xC0 /* 2nd line at position 40 */
#define LCD_LINE_3 0x94 /* 3nd line at position 14 */
#define LCD_LINE_4 0xD4 /* 4nd line at position 54 */

and...You are right:

LcdWriteCmd(0x0E); //display on, Cursor on, blink on

not LcdWriteCmd(0x0C);

:D

Thank you very much!

Good luck to you! :D
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top