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.

[SOLVED] interfacing two alpha numeric LCD with PIC controller

Status
Not open for further replies.

mrarslanahmed

Full Member level 2
Full Member level 2
Joined
Nov 15, 2011
Messages
143
Helped
6
Reputation
12
Reaction score
6
Trophy points
1,298
Location
gujranwala pakistan
Activity points
2,206
hi

i working on pic 16f887 and using mikroc pro for programming, i am trying to interface two lcd with the controller, i have made function of each lcd for initialisation and data, when i use one data sending function at a time, system is ok, but when i use both data function , the system starts giving problem, content for one lcd are send to other lcd as well i have attached code below ,



Code:
// LCD module connections
sbit LCD_RS at RB3_bit;
sbit LCD_EN at RB2_bit;
sbit LCD_D4 at RB4_bit;
sbit LCD_D5 at RB5_bit;
sbit LCD_D6 at RB6_bit;
sbit LCD_D7 at RB7_bit;

sbit LCD_RS_Direction at TRISB3_bit;
sbit LCD_EN_Direction at TRISB2_bit;
sbit LCD_D4_Direction at TRISB4_bit;
sbit LCD_D5_Direction at TRISB5_bit;
sbit LCD_D6_Direction at TRISB6_bit;
sbit LCD_D7_Direction at TRISB7_bit;

// End LCD module connections


void init_main();
void Lcd2_init();
void LCD_break(unsigned int);
void lcd2_command(unsigned int);
void lcd2_data_string(char*);
void Break_data_lcd2(char);

void main()
{
     init_main();
     Lcd_Cmd(_LCD_CLEAR);
     LCD_OUT(1,1,"LCD1");
     lcd2_data_string("abcd");

}
void init_main()
{
     OSCCON=0x71;
     Delay_ms(50);

     TRISA=0;
     TRISB=0;
     TRISC=0;
     TRISD=0;
     TRISE=0;

     ANSEL  = 0;                                                                // Configure AN pins as digital I/O
     ANSELH = 0;
     C1ON_bit = 0;                                                              // Disable comparators
     C2ON_bit = 0;
     
     PORTA=0;
     PORTB=0;
     PORTC=0;
     PORTD=0;
     PORTE=0;

     Lcd2_init();
     lcd_init();
     Lcd_Cmd(_LCD_CLEAR);               // Clear display
     Lcd_Cmd(_LCD_CURSOR_OFF);          // Cursor off

}
void Lcd2_init()
{
     LCD_break(0x02);
     LCD_break(0x28);
                                                                                //LCD_break(0x08); // display off
     LCD_break(0x0F);                                                           // display on

     LCD_break(0x0C);
     LCD_break(0x06);                                                           
     LCD_break(0x80);
}
void LCD_break(unsigned int LCD_break)
{
     int temp_lcd_break;
     temp_lcd_break=(LCD_break & 0xF0);                                       // Mask lower nibble because RB4-RB7 pins are being used
     lcd2_command(temp_lcd_break);
     temp_lcd_break=((LCD_break<<4) & 0xF0);                                  // Mask lower nibble because RB4-RB7 pins are being used
     lcd2_command(temp_lcd_break);
}
void lcd2_command(unsigned int lcd_cmd)
{
     portc=lcd_cmd;
     portc.Rc3=0;                                                                // RS it is a command
     portc.RC2=1;                                                                // RS it is a command
     Delay_ms(10);
     portc.RC2=0;
     LCD_CMD=0;
}
void  lcd2_data_string(char* lcd2_string)
{
    int temp;
    for(temp=0;temp<=16;temp++)
    {
       if(!lcd2_string)
       break;
        Break_data_lcd2(lcd2_string[temp]);
        Delay_ms(25);
    }
    lcd2_string="";
}
void Break_data_lcd2(char data_lcd2)
{
     char temp_data_lcd2;
     temp_data_lcd2=(data_lcd2&0xF0);
     portc=temp_data_lcd2;
     portc.rc3=1;                                                               // register select 1 for data
     portc.rc2=1;                                                               // enable
     Delay_ms(10);
     portc.rc2=0;

     temp_data_lcd2=((data_lcd2<<4)&0xF0);
     portc=temp_data_lcd2;
     portc.rc3=1;                                                               // register select 1 for data
     portc.rc2=1;                                                               // register select 1 for data
     Delay_ms(10);
     portc.rc2=0;         
     temp_data_lcd2="";
}

i will be very pleased if some one can help me in this regard
 

Use same pins of PIC to drive D4 to D7 of both LCDs. Also for RS pin but use seperate pins to drive EN pins of LCD.
 

I think it is impossible to redefine pins with internal library. You will have to use your own library or make a logic switch externaly for 'E' pin for each lcd.
 

i really loved your approach.. i have never thought to use serial to parallel shift register in this way thus saving lot of money with some more coding using bit-banging concept..
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top