Loading ...
Sorry, an error occurred while loading the content.

LCD Interfacing Problem with Atmega16!!

Expand Messages
  • nilay_space
    Hello all, I have been trying to display some text on my 16*2 JHD162A LCD module. But it does not display anything. I see only black rectangles on the
    Message 1 of 3 , Jun 24, 2008
    • 0 Attachment
      Hello all,
      I have been trying to display some text on my 16*2 JHD162A
      LCD module. But it does not display anything. I see only black
      rectangles on the lowerline. I use BASCOM-AVR sample code to program
      the chip.
      I am including the code below:

      $regfile = "m16def.dat"
      $crystal = 1000000
      '$sim
      $lib "lcd4.lbx" ' use the alternative library


      'in order for simulation to work correct, you need to specify the used
      'pins
      'for lcd4.lbx, the pins are fixed
      'Rs = PortB.0
      'RW = PortB.1 we dont use the R/W option of the LCD in this
      version so connect to ground
      ' E = PortB.2
      'E2 = PortB.3 optional for lcd with 2 chips
      'Db4 = PortB.4 the data bits must be in a nibble to save code
      'Db5 = PortB.5
      'Db6 = PortB.6
      'Db7 = PortB.7

      Config Lcdpin = Pin , Rs = Portb.0 , E = Portb.2 , Db4 = Portb.4 , Db5
      = Portb.5 , Db6 = Portb.6 , Db7 = Portb.7

      Config Lcd = 16 * 2

      Cls
      Lcd "test"
      Lowerline
      Lcd "12345678"
      End

      Now my LCD has KS0066 control driver. So could it be a problem? Most
      of the websites mention it compatible with HD44780. I rechecked all my
      connections. All the connections are mentioned in the code above. $lib
      "lcd4.lbx" initializes the LCD.
      I would like someone to give some insights onto this...
    • nitin chaudhary
      ... From: nilay_space Subject: [booksbybibin,www.booksbybibin.tk] LCD Interfacing Problem with Atmega16!! To:
      Message 2 of 3 , Jun 26, 2008
      • 0 Attachment
        --- On Tue, 24/6/08, nilay_space <nilay_space@...> wrote:
        From: nilay_space <nilay_space@...>
        Subject: [booksbybibin,www.booksbybibin.tk] LCD Interfacing Problem with Atmega16!!
        To: booksbybibin@yahoogroups.com
        Date: Tuesday, 24 June, 2008, 6:08 PM
















        Hello all,

        I have been trying to display some text on my 16*2 JHD162A

        LCD module. But it does not display anything. I see only black

        rectangles on the lowerline. I use BASCOM-AVR sample code to program

        the chip.

        I am including the code below:



        $regfile = "m16def.dat"

        $crystal = 1000000

        '$sim

        $lib "lcd4.lbx" ' use the alternative library



        'in order for simulation to work correct, you need to specify the used

        'pins

        'for lcd4.lbx, the pins are fixed

        'Rs = PortB.0

        'RW = PortB.1 we dont use the R/W option of the LCD in this

        version so connect to ground

        ' E = PortB.2

        'E2 = PortB.3 optional for lcd with 2 chips

        'Db4 = PortB.4 the data bits must be in a nibble to save code

        'Db5 = PortB.5

        'Db6 = PortB.6

        'Db7 = PortB.7



        Config Lcdpin = Pin , Rs = Portb.0 , E = Portb.2 , Db4 = Portb.4 , Db5

        = Portb.5 , Db6 = Portb.6 , Db7 = Portb.7



        Config Lcd = 16 * 2



        Cls

        Lcd "test"

        Lowerline

        Lcd "12345678"

        End



        Now my LCD has KS0066 control driver. So could it be a problem? Most

        of the websites mention it compatible with HD44780. I rechecked all my

        connections. All the connections are mentioned in the code above. $lib

        "lcd4.lbx" initializes the LCD.

        I would like someone to give some insights onto this...







        If you are using lcd for the first time, don't use predefined functions and libraries to do it.

        Simple way ti make lcd work is

        1). Make RW line always low
        2). Make EN line low
        3). Make RS line low (means value is control word)
        4). Give 0x01 to data lines(eight not four) and give a high to low pulse on EN pin(high -- 5-10ms delay -- low) to accept.
        5). Do the same(step 4) for the following values -- 0x38;0x0c; 0x06; 0x80;. These are initialization codes or control words

        6). Now your lcd is ready to accept data. Now, make RS High.
        7). Give the word to data lines which you want to print and then give a high to low pulse to EN line(high -- 5-10ms delay -- low).Repeat it for further words which you want to be displayed.

































        Bollywood, fun, friendship, sports and more. You name it, we have it on http://in.promos.yahoo.com/groups/bestofyahoo/
      • Ashish
        ... I also hv similar problem while interfacing lcd JHD162A with atmega32.I also carried out suggestions in answer to prob.I hv simulated in proteus also .
        Message 3 of 3 , Mar 13, 2010
        • 0 Attachment
          --- In booksbybibin@yahoogroups.com, nitin chaudhary <nitin2162000@...> wrote:
          >
          >
          >
          > --- On Tue, 24/6/08, nilay_space <nilay_space@...> wrote:
          > From: nilay_space <nilay_space@...>
          > Subject: [booksbybibin,www.booksbybibin.tk] LCD Interfacing Problem with Atmega16!!
          > To: booksbybibin@yahoogroups.com
          > Date: Tuesday, 24 June, 2008, 6:08 PM
          >
          >
          >
          >
          >
          >
          >
          >
          >
          >
          >
          >
          >
          >
          >
          >
          > Hello all,
          >
          > I have been trying to display some text on my 16*2 JHD162A
          >
          > LCD module. But it does not display anything. I see only black
          >
          > rectangles on the lowerline. I use BASCOM-AVR sample code to program
          >
          > the chip.
          >
          > I am including the code below:
          >
          >
          >
          > $regfile = "m16def.dat"
          >
          > $crystal = 1000000
          >
          > '$sim
          >
          > $lib "lcd4.lbx" ' use the alternative library
          >
          >
          >
          > 'in order for simulation to work correct, you need to specify the used
          >
          > 'pins
          >
          > 'for lcd4.lbx, the pins are fixed
          >
          > 'Rs = PortB.0
          >
          > 'RW = PortB.1 we dont use the R/W option of the LCD in this
          >
          > version so connect to ground
          >
          > ' E = PortB.2
          >
          > 'E2 = PortB.3 optional for lcd with 2 chips
          >
          > 'Db4 = PortB.4 the data bits must be in a nibble to save code
          >
          > 'Db5 = PortB.5
          >
          > 'Db6 = PortB.6
          >
          > 'Db7 = PortB.7
          >
          >
          >
          > Config Lcdpin = Pin , Rs = Portb.0 , E = Portb.2 , Db4 = Portb.4 , Db5
          >
          > = Portb.5 , Db6 = Portb.6 , Db7 = Portb.7
          >
          >
          >
          > Config Lcd = 16 * 2
          >
          >
          >
          > Cls
          >
          > Lcd "test"
          >
          > Lowerline
          >
          > Lcd "12345678"
          >
          > End
          >
          >
          >
          > Now my LCD has KS0066 control driver. So could it be a problem? Most
          >
          > of the websites mention it compatible with HD44780. I rechecked all my
          >
          > connections. All the connections are mentioned in the code above. $lib
          >
          > "lcd4.lbx" initializes the LCD.
          >
          > I would like someone to give some insights onto this...
          >
          >
          >
          >
          >
          >
          >
          > If you are using lcd for the first time, don't use predefined functions and libraries to do it.
          >
          > Simple way ti make lcd work is
          >
          > 1). Make RW line always low
          > 2). Make EN line low
          > 3). Make RS line low (means value is control word)
          > 4). Give 0x01 to data lines(eight not four) and give a high to low pulse on EN pin(high -- 5-10ms delay -- low) to accept.
          > 5). Do the same(step 4) for the following values -- 0x38;0x0c; 0x06; 0x80;. These are initialization codes or control words
          >
          > 6). Now your lcd is ready to accept data. Now, make RS High.
          > 7). Give the word to data lines which you want to print and then give a high to low pulse to EN line(high -- 5-10ms delay -- low).Repeat it for further words which you want to be displayed.
          >
          >
          >
          >
          >
          >
          >
          >
          >
          >
          >
          >
          >
          >
          >
          >
          >
          >
          >
          >
          >
          >
          >
          >
          >
          >
          >
          >
          >
          >
          >
          >
          >
          > Bollywood, fun, friendship, sports and more. You name it, we have it on http://in.promos.yahoo.com/groups/bestofyahoo/
          >
          I also hv similar problem while interfacing lcd JHD162A with atmega32.I also carried out suggestions in answer to prob.I hv simulated in proteus also . But the problem is still there.Ckt diagram and code(in code vision)is attached . Plz help me.
          code is atached is follows:
          /*****************************************************
          This program was produced by the
          CodeWizardAVR V2.04.2c Evaluation
          Automatic Program Generator
          © Copyright 1998-2009 Pavel Haiduc, HP InfoTech s.r.l.
          http://www.hpinfotech.com

          Project :
          Version :
          Date : 3/13/2010
          Author : Freeware, for evaluation and non-commercial use only
          Company :
          Comments:


          Chip type : ATmega32L
          Program type : Application
          AVR Core Clock frequency: 1.000000 MHz
          Memory model : Small
          External RAM size : 0
          Data Stack size : 512
          *****************************************************/

          #include <mega32.h>
          #include <delay.h>
          // Declare your global variables here

          //Hardware connections
          //d0-d7 of lcd =PORTD
          //a.7=rs,a.6=rw,a.5=en

          void cmd(unsigned char val)
          {
          //rs=0 rw=0 en=1
          PORTD=val;
          PORTB=0x20 ;
          delay_ms(10);
          //rs=0 rs=0 en=0
          PORTB=0x00;
          delay_ms(250);
          return;
          }
          void data(unsigned char val)
          {
          //rs=1 rw=0 en=1
          PORTD=val;
          PORTB=0xA0;
          delay_ms(10);
          //rs=0 rs=0 en=0
          PORTB=0x80;
          delay_ms(250);
          return;
          }
          void main(void)
          {
          // Declare your local variables here

          // Input/Output Ports initialization
          // Port A initialization
          // Func7=In Func6=In Func5=In Func4=In Func3=In Func2=In Func1=In Func0=In
          // State7=T State6=T State5=T State4=T State3=T State2=T State1=T State0=T
          PORTA=0x00;
          DDRA=0x00;

          // Port B initialization
          // Func7=Out Func6=Out Func5=Out Func4=Out Func3=Out Func2=Out Func1=Out Func0=Out
          // State7=0 State6=0 State5=0 State4=0 State3=0 State2=0 State1=0 State0=0
          PORTB=0x00;
          DDRB=0xFF;

          // Port C initialization
          // Func7=In Func6=In Func5=In Func4=In Func3=In Func2=In Func1=In Func0=In
          // State7=T State6=T State5=T State4=T State3=T State2=T State1=T State0=T
          PORTC=0x00;
          DDRC=0x00;

          // Port D initialization
          // Func7=Out Func6=Out Func5=Out Func4=Out Func3=Out Func2=Out Func1=Out Func0=Out
          // State7=0 State6=0 State5=0 State4=0 State3=0 State2=0 State1=0 State0=0
          PORTD=0x00;
          DDRD=0xFF;

          // Timer/Counter 0 initialization
          // Clock source: System Clock
          // Clock value: Timer 0 Stopped
          // Mode: Normal top=FFh
          // OC0 output: Disconnected
          TCCR0=0x00;
          TCNT0=0x00;
          OCR0=0x00;

          // Timer/Counter 1 initialization
          // Clock source: System Clock
          // Clock value: Timer1 Stopped
          // Mode: Normal top=FFFFh
          // OC1A output: Discon.
          // OC1B output: Discon.
          // Noise Canceler: Off
          // Input Capture on Falling Edge
          // Timer1 Overflow Interrupt: Off
          // Input Capture Interrupt: Off
          // Compare A Match Interrupt: Off
          // Compare B Match Interrupt: Off
          TCCR1A=0x00;
          TCCR1B=0x00;
          TCNT1H=0x00;
          TCNT1L=0x00;
          ICR1H=0x00;
          ICR1L=0x00;
          OCR1AH=0x00;
          OCR1AL=0x00;
          OCR1BH=0x00;
          OCR1BL=0x00;

          // Timer/Counter 2 initialization
          // Clock source: System Clock
          // Clock value: Timer2 Stopped
          // Mode: Normal top=FFh
          // OC2 output: Disconnected
          ASSR=0x00;
          TCCR2=0x00;
          TCNT2=0x00;
          OCR2=0x00;

          // External Interrupt(s) initialization
          // INT0: Off
          // INT1: Off
          // INT2: Off
          MCUCR=0x00;
          MCUCSR=0x00;

          // Timer(s)/Counter(s) Interrupt(s) initialization
          TIMSK=0x00;

          // Analog Comparator initialization
          // Analog Comparator: Off
          // Analog Comparator Input Capture by Timer/Counter 1: Off
          ACSR=0x80;
          SFIOR=0x00;

          while (1)
          {
          // Place your code here
          cmd(0x01);
          delay_ms(1000);
          cmd(0x38);
          delay_ms(1000);
          cmd(0x0C);
          delay_ms(1000);
          cmd(0x06);
          delay_ms(1000);
          cmd(0x80);
          delay_ms(1000);
          data('M');
          delay_ms(1000);
          data('D');
          delay_ms(1000);
          data('E');
          delay_ms(1000);
          };
          }
        Your message has been successfully submitted and would be delivered to recipients shortly.