Thread: PIC18F4520 interfacing with hitachi 44780

  1. #16
    TEIAM - problem solved
    Join Date
    Apr 2012
    Location
    Melbourne Australia
    Posts
    1,907
    What type of multimeter? Usually, beeps are associated with resistance readings (i.e. short circuits, or <100 ohms). I'm not familiar with meters that beep for voltage readings.
    The "beep" is usually know as a "continuity test" and is used for finding short circuits - I think that the OP is saying that they suspect that there is no connection between RD5 and LCD's r/w

    Make sure that there is no power to the circuit before testing. Also, some modules don't support reading of LCD screens, so they are tied to the voltage level associated with reading.

    Make sure you have read this a few times from top to bottom, taking notes as you go http://www.sparkfun.com/datasheets/LCD/HD44780.pdf
    Fact - Beethoven wrote his first symphony in C

  2. #17
    Registered User
    Join Date
    Jun 2011
    Posts
    4,513
    The "beep" is usually know as a "continuity test" and is used for finding short circuits
    Yes, as I said: "Usually, beeps are associated with resistance readings (i.e. short circuits, or <100 ohms)"

    I think that the OP is saying that they suspect that there is no connection between RD5 and LCD's r/w
    You are likely correct. For some reason, I assumed they were referring to a voltage reading, but upon re-reading the post, there was no valid reason for me to make that assumption.

  3. #18
    Registered User
    Join Date
    Dec 2012
    Posts
    12
    yea first time,,
    Code:
    //turns watch dog timer off, turn low voltage programming off
    #pragma config WDT=OFF, LVP=OFF, DEBUG=ON, MCLRE = OFF
     
    #pragma config OSC = LP
    #define _XTAL_FREQ 4000000
     
    #include <p18f4520.h>
    #include <delays.h>
     
     
    //LCD (PortD)
    #define  E LATDbits.LATD6
    #define  R_W LATDbits.LATD5
    #define  RS  LATDbits.LATD4
    #define LCDdata LATD
    #define LCD_PWR LATDbit.LATD7
     
    void command(unsigned char);
    void write(unsigned char);
    void Nybble(unsigned char);
    void init(void);
    void PutMessage(const rom char *);
     
    void main()
    {   
        ADCON1 = 0x0F;                //make RA0 digital
     
           //data direction registers all 0's mean that all pins are set to output
     //all 1's means that all of the pins are set to operate as inputs
     TRISA = 0x00;  
     TRISB = 0x00; 
     TRISD = 0x00;
            init();
            PutMessage(" Hello World!");
            command(0xc0);
            PutMessage(" WELCOME");
            while(1);
    }
     
    //Write a string to the LCD
    void PutMessage(const rom char *Message)
    {
    const rom char *Pos = Message;
     while(*Pos!=0)
         write(*Pos++);
    }
     
    /**********************************************************/
    //4-bit methods for LCD
    /**********************************************************/
    void command(unsigned char i)
    {
     RS =0;
     R_W =0;          //R/W=LOW : Write
     Nybble(i>>4);    //Send upper 4 bits
     Nybble(i);       //Send lower 4 bits
     Delay1KTCYx(2);  //must wait at least 2mS (2*1000*4/1e6 = 8ms used)
    }
     
    void write(unsigned char i)
    {
     RS =1;
     R_W =0;          //R/W=LOW : Write
     Nybble(i>>4);    //Send upper 4 bits
     Nybble(i);       //Send lower 4 bits
     Delay1KTCYx(2);  //must wait 2mS
    }
     
    /**********************************************************/
    void Nybble(unsigned char dat)
    {
        dat &= 0x0f;             //clear top bits of dat
        LCDdata &= 0xf0;         //clear bottom bits of port (interested only in DB7-DB4)
        LCDdata |= dat;          //or the two and store at port
        E = 1;
        Delay1TCY();             //enable pulse width >= 300ns (used 4uS)
        E = 0;                   //Clock enable: falling edge
    }
     
    /**********************************************************/

  4. #19
    Registered User
    Join Date
    Jun 2011
    Posts
    4,513
    First, if you haven't already, get a copies of the data sheets and read through them:

    - PIC18F4520: http://ww1.microchip.com/downloads/e...Doc/39631E.pdf
    - hitachi 44780: http://www.sparkfun.com/datasheets/LCD/HD44780.pdf

    There are instructions on how to explicitly initialize the LCD on page 45, in case it does not automatically initialize - it would probably be a good idea to read through that.

    Page 45 also indicates that you should be giving the LCD time before beginning to write commands to it - at least 15 ms. This is something I don't see in your code.

    Your RS, R_W, and E settings appear to be correct, at a quick look.

    There's not much more I can personally do without digging into the documentation, and without the hardware at my disposal. Try adding the delay before controlling the LCD. If this doesn't do it, try the initialization as listed in the data sheet.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 8
    Last Post: 08-02-2012, 06:15 PM
  2. PIC16F684 Interfacing with Hitachi 44780
    By JTerry in forum C Programming
    Replies: 36
    Last Post: 12-13-2010, 12:13 PM
  3. interfacing c and java..
    By vapanchamukhi in forum C Programming
    Replies: 4
    Last Post: 09-18-2008, 02:10 PM
  4. interfacing with a program
    By Crazed in forum Windows Programming
    Replies: 10
    Last Post: 03-17-2008, 05:29 AM
  5. interfacing assembler with c++
    By Unregistered in forum C++ Programming
    Replies: 2
    Last Post: 10-24-2001, 12:13 AM