Does LCD display anything?

Discussion in 'Embedded Systems and Microcontrollers' started by corefinder, Feb 11, 2014.

  1. corefinder

    Thread Starter Member

    Oct 6, 2011
    55
    0
    Hi everyone,
    I was interfacing lcd JHD162a with AT89S52 atmel microcontoller. I made a code and burned in the processor but LCD didn't display anything. According to the code it should initialise lcd and cursor must be blinking. I made the program in micro proc for 8051 by Microelectronika.
    Code ( (Unknown Language)):
    1.  
    2. sbit LCD_RS at P2_0_bit;
    3. sbit LCD_EN at P2_1_bit;
    4.  
    5. sbit LCD_D4 at P2_4_bit;
    6. sbit LCD_D5 at P2_5_bit;
    7. sbit LCD_D6 at P2_6_bit;
    8. sbit LCD_D7 at P2_7_bit;
    9. // End Lcd module connections
    10. void main()
    11. {
    12.   Lcd_Init();                       // initialise lcd
    13.   Delay_ms(100);                    // command Lcd
    14.   LCD_EN=0;
    15.   LCD_RS=0;
    16.   LCD_D4=0;
    17.   LCD_D5=0;
    18.   LCD_D6=0;
    19.   LCD_D7=0;
    20.   LCD_EN=0;
    21.   Delay_ms(500);
    22.   LCD_EN=1;
    23.   Delay_ms(100);
    24.   LCD_D4=1;
    25.   LCD_D5=1;
    26.   LCD_D6=1;
    27.   LCD_D7=0;
    28.   LCD_EN=1;
    29.   Delay_ms(500);
    30.   LCD_EN=0;
    31.   }
    32.  
    I want to know whether problem is in the program or lcd is faulty.So if any of you have access to these devices kindly check the code provided and see if lcd is displaying lcd. I have attached its hex file and datasheet of lcd.
     
  2. t06afre

    AAC Fanatic!

    May 11, 2009
    5,939
    1,222
    I see some thing here. You must add a variable resistor for contrast adjustment like shown in the picture. Also if you want to use 4 bit interface. You must copy the flowchart on page 10 in the datasheet exactly. That is VERY important. So far you have not done that.
     
  3. corefinder

    Thread Starter Member

    Oct 6, 2011
    55
    0
    That flowchart is about initialization of LCD I used a function Lcd_Int() int the code. It calls the already defined function by compiler ,the function automatically initializes LCD which have all HD4470 compliant controllers.
    SO it should not be a problem. Also i write code exaclty like one in flowchart but that is also not working!!
    This is what I got from flowchart please tell if I did any error.
    Code ( (Unknown Language)):
    1.  
    2. void Lcd_Init1()
    3. {
    4. LCD_RS=0;
    5. LCD_EN=0;
    6. Delay_ms(50);
    7. LCD_D4=0;
    8. LCD_D5=0;
    9. LCD_D6=0;
    10. LCD_D7=0;
    11. LCD_D4=1;
    12. LCD_D5=1;
    13. LCD_EN=1;
    14. Delay_ms(10);
    15. LCD_EN=0;
    16. Delay_ms(50);
    17. LCD_EN=1;
    18. Delay_ms(10);
    19. LCD_EN=0;
    20. Delay_ms(200);
    21. LCD_EN=1;
    22. Delay_ms(10);
    23. LCD_EN=0;
    24. Delay_ms(100);
    25. LCD_D4=0;
    26. LCD_D5=1;
    27. LCD_EN=1;
    28. Delay_ms(10);
    29. LCD_EN=0;
    30. Delay_ms(10);
    31. LCD_D4=0;       /* d4=0,d5=1 next d7=1 */
    32. LCD_D5=1;
    33. LCD_EN=1;
    34. Delay_ms(10);
    35. LCD_EN=0;
    36. LCD_D5=0;
    37. LCD_D7=1;
    38. LCD_EN=1;
    39. Delay_ms(10);
    40. LCD_EN=0;
    41. Delay_ms(10);
    42. LCD_D4=0;    /* next cycle*/
    43. LCD_D5=0;
    44. LCD_D6=0;
    45. LCD_D7=0;
    46. LCD_EN=1;
    47. Delay_ms(10);
    48. LCD_EN=0;
    49. LCD_D7=1;
    50. LCD_EN=1;
    51. Delay_ms(10);
    52. LCD_EN=0;
    53. Delay_ms(10);
    54. LCD_D4=0;  /*next cycle*/
    55. LCD_D5=0;
    56. LCD_D6=0;
    57. LCD_D7=0;
    58. LCD_EN=1;
    59. Delay_ms(10);
    60. LCD_EN=0;
    61. LCD_D4=1;
    62. LCD_EN=1;
    63. Delay_ms(100);
    64. LCD_EN=0;
    65. Delay_ms(10);
    66. LCD_D4=0; /*last cycle*/
    67. LCD_D5=0;
    68. LCD_D6=0;
    69. LCD_D7=0;
    70. LCD_EN=1;
    71. Delay_ms(10);
    72. LCD_EN=0;
    73. LCD_D4=1;
    74. LCD_D5=1;
    75. LCD_D6=1;
    76. LCD_D7=0;
    77. LCD_EN=1;
    78. Delay_ms(10);
    79. LCD_EN=0;
    80. Delay_ms(100);
    81. }
    82.  
     
  4. t06afre

    AAC Fanatic!

    May 11, 2009
    5,939
    1,222
    Is your R/W pin tied low?
     
  5. MrChips

    Moderator

    Oct 2, 2009
    12,413
    3,353
    Is the contrast connection (pin-3) correctly connected to a contrast potentiometer (or at least with a 1kΩ resistor to GND)?

    When you first apply power do you get black rectangles on the display?
     
  6. corefinder

    Thread Starter Member

    Oct 6, 2011
    55
    0
    Yes I have tied R/W pin low.
     
  7. corefinder

    Thread Starter Member

    Oct 6, 2011
    55
    0
    Yes I have put varistor to pin-3 and when I reduce resistance I see black boxes only in 1st row.
     
  8. spinnaker

    AAC Fanatic!

    Oct 29, 2009
    4,866
    988
    What have you done to troubleshoot your problem?

    Step through your code with the debugger. When you get to the place where data is output to the LCD. Veirify with scope, logic analyzer, logic probe or DMM that you see the correct data at the LCD pins.

    If that is all correct then the next step is to look at timing.

    The two main issues with LCD are contrast pin already mentioned and timing.
     
Loading...