1. mahmood102

    Thread Starter New Member

    Jan 18, 2013
    23
    0
    hi
    i connect the lcd 1602a with pic16f877a and i write the code to display hello world but i did not see any thing on the lcd

    can any one help me please
     
  2. tshuck

    Well-Known Member

    Oct 18, 2012
    3,531
    675
    How about a schematic. We can't help without one....
     
  3. mahmood102

    Thread Starter New Member

    Jan 18, 2013
    23
    0
    RS at RD0
    EN at RD1
    LCD_D4 at RD4
    LCD_D5 at RD5
    LCD_D6 at RD6
    LCD_D7 at RD7
    pin1 of lcd at GND
    pin2 of lcd at +5v
    pin3 of lcd to variable resistor 10k
     
  4. t06afre

    AAC Fanatic!

    May 11, 2009
    5,939
    1,222
    That is not a schematic. You need to draw the schematic and post it. Also the code important. And we need you to post all of it. Not just some part of it.
     
  5. tshuck

    Well-Known Member

    Oct 18, 2012
    3,531
    675
    hmmm... that doesn't look like a schematic...

    So you are using a character LCD display and is probably a HD44780 type, no?

    Looks also like you are trying to run it in 4-bit mode, despite the fact that you have plenty of I/O, is there a reason for that?

    Anyway, post your code, your schematic, and what you've done to debug the problem and we can move along.:)
     
  6. mahmood102

    Thread Starter New Member

    Jan 18, 2013
    23
    0
    sbit LCD_RS at RD0_bit;
    sbit LCD_EN at RD1_bit;
    sbit LCD_D4 at RD4_bit;
    sbit LCD_D5 at RD5_bit;
    sbit LCD_D6 at RD6_bit;
    sbit LCD_D7 at RD7_bit;
    sbit LCD_RS_Direction at TRISD0_bit;
    sbit LCD_EN_Direction at TRISD1_bit;
    sbit LCD_D4_Direction at TRISD4_bit;
    sbit LCD_D5_Direction at TRISD5_bit;
    sbit LCD_D6_Direction at TRISD6_bit;
    sbit LCD_D7_Direction at TRISD7_bit;
    // End LCD module connection definition
    //3- Define Messages
    char message1[] = "Welcome to";
    char message2[] = "ENG.F.ABDELAZIZ";
    //4- Main function
    void main()
    {
    //4-a- set up ports
    TRISD = 0; // PORTD All Outputs
    PORTD=0; // clear

    //4-b- set up LCD
    Lcd_Init(); // Initialize LCD
    Lcd_Cmd(_LCD_CLEAR); // CLEAR display
    Lcd_Cmd(_LCD_CURSOR_OFF); // Cursor off
    // 4-c- Infinite Loop
    while(1) {

    //4-c-1-send strings
    Lcd_Out(1,4,message1); // Write message1 in 1st row,begin from Column 4
    Lcd_Out(2,1,message2); // Write message2 in 2nd row,begin from Column 1
    //4-c-2--delay 1 sec.
    Delay_ms(1000); // Wait for 1 sec
    //4-c-3--clear LCD
    Lcd_Cmd(_LCD_CLEAR); // Clear display
    //4-c-4-delay 1 sec.
    Delay_ms(1000); // Wait for 1 sec
    } // Infinite Loop
    }
     
  7. mahmood102

    Thread Starter New Member

    Jan 18, 2013
    23
    0
    is this ok
     
  8. tshuck

    Well-Known Member

    Oct 18, 2012
    3,531
    675
    Yes, although you should use the code tags when pasting code... it's in the toolbar as the '#' symbol...

    I see one REALLY big problem... you have no oscillator. the 16F877A doesn't have an internal oscillator.....
     
  9. mahmood102

    Thread Starter New Member

    Jan 18, 2013
    23
    0
    sorry this drawing just the connection for the lcd .
    but for the pic i used 4mhz oscillator.
    i test the code for the led and its work but know i tray to make the connection with lcd to display the message but its not work
     
  10. tshuck

    Well-Known Member

    Oct 18, 2012
    3,531
    675
    :(
    So, it's a partial schematic....
     
  11. tshuck

    Well-Known Member

    Oct 18, 2012
    3,531
    675
    Are you using a library for your LCD_X routines? If so, which? If not, post these functions..


    Basically, we need to see what's going on here, post your full code...
     
  12. mahmood102

    Thread Starter New Member

    Jan 18, 2013
    23
    0
    ok can you tell what can i do
    or why the lcd not working
    if you can please tell how can i connect the lcd to this pic and display a message on it
     
  13. mahmood102

    Thread Starter New Member

    Jan 18, 2013
    23
    0
    this is the full code i am use it by mikroC
     
  14. t06afre

    AAC Fanatic!

    May 11, 2009
    5,939
    1,222
    Ok so this setup work in Proteus. But not in the real world is that correct? Or do you struggle just to make it work in Proteus
     
  15. mahmood102

    Thread Starter New Member

    Jan 18, 2013
    23
    0
    this is the full code which i use it in mikroC
     
  16. mahmood102

    Thread Starter New Member

    Jan 18, 2013
    23
    0
    No.
    i have the components
    i tray by programming the pic then i connected with lcd and test it.
     
  17. tshuck

    Well-Known Member

    Oct 18, 2012
    3,531
    675
    Then where are the Lcd routines defined?

    Without knowing what you are using, I can only guess...

    The library you are using may assume an 8-bit interface, which will cause your 4-bit interface to not work.

    Your Lcd_Init() may not be taking into account the 4MHz clock you have and the timings may be off...
     
  18. mahmood102

    Thread Starter New Member

    Jan 18, 2013
    23
    0
    i am new with pic so please tell what i have to do
     
  19. t06afre

    AAC Fanatic!

    May 11, 2009
    5,939
    1,222
    Have you set the configuration bits properly?
     
  20. mahmood102

    Thread Starter New Member

    Jan 18, 2013
    23
    0
    ok
    forget every thing i am do it.
    can you tell what i have to do to connect the lcd with pic16f877a and write a simple code for test it.
     
Loading...