dspic30f4011 lcd interface

Discussion in 'Programmer's Corner' started by bassplayer142, May 25, 2010.

  1. bassplayer142

    Thread Starter Active Member

    Jan 2, 2007
    89
    0
    I am trying to interface a standard type hd44780 lcd screen to my micro in 4 bit mode. I found the following link for a different micro but after modification I can't seem to get it to work.

    http://ghmicro.com/index.php?option...9:dspic-30f4013-lcd&catid=11:30f4013&Itemid=2

    I changed the three RS RW and E pins to other pins on my micro and changed the 4 bit lines from port b (9-12) to my port b (5-8). I then changed the bit shifting to accompany this pin change as seen in the lcd_cmd and lcd_char functions.

    Considering that the R/W pin is used, I don't have to worry about delays because the lcd uses a busy signal. But, since I'm running my dspic at 7.5MHz with a 16X multiplier I'm thinking that timing has something to do with it anyway. When you toggle the E pin from 1 back to 0 I had to put a delay in between for anything to show up. But all I get to show up is garbage characters.

    Sorry for such a long post, but any help with these timing issues or anything would be greatly appreciated. Thanks!
     
  2. bassplayer142

    Thread Starter Active Member

    Jan 2, 2007
    89
    0
    So I simplified the procedure to get it working with 8 bits and grounded the RW pin. Now I can get strings and chars to come on the display but they are both on the second line of the lcd display.

    I have sent both 0x80 (line1) and 0xC0 (line2) to no avail. Also, I commanded 0x38 to set the lcd into 8bit mode with 2 lines. thanks.

    I also find when I toggle the enable line before sending the command then it works but posts every character twice. If I were to put hello it would display "hheelllloo".

    void lcd_cmd(unsigned char letter)
    {
    et(); //two characters et() toggles EN
    E = 0;
    msdelay(2);
    LATB = letter;
    RS = 0;
    et();
    msdelay(5);

    }
     
    Last edited: May 28, 2010
  3. rjenkins

    AAC Fanatic!

    Nov 6, 2005
    1,015
    69
    The sequence should be to set the register select bit & data, then pulse E for about 0.5 or 1uS, depending on the controller specs.

    The other signals should only change while E is not active.

    Which line you display on depends on the LCD memory location you write to.
    If I remember correctly, address 0 is the start of the first line and address 40 ($28) is the start of the second line.
     
  4. bassplayer142

    Thread Starter Active Member

    Jan 2, 2007
    89
    0
    thanks for the reply, i will look into this more later.
     
Loading...