PIC18F4525 & LCD simple code problem


Closed Thread
Results 1 to 8 of 8
  1. #1
    Join Date
    Nov 2007
    Posts
    13

    Default PIC18F4525 & LCD simple code problem

    Hi,

    I am new to any kind of programming and I am using PicBasic Pro to program PIC18F4525. I am hooking up the PIC to a parallel LCD screen which has HD44780 controller (16X2). I am just trying to test the connection and the working of the LCD by writing a code which displays a one line test statement. I am using Micro Code Studio.

    The LCD screen is not displaying the message I want it to and remains blank. I know this is a very minor issue, but I am doing this stuff for the first time !!!

    The LCD is connected to 4 pins of the PIC, since it is in 4 bit mode.

    Please help me out with this....I would really appreciate it !!!


    Here is the code -


    DEFINE OSC 20

    '******Setting up the LCD display******

    DEFINE LCD_DREG PORTB
    DEFINE LCD_DBIT 4
    DEFINE LCD_RSREG PORTB
    DEFINE LCD_RSBIT 7
    DEFINE LCD_EREG PORTB
    DEFINE LCD_EBIT 6
    DEFINE LCD_BITS 4
    DEFINE LCD_LINES 2
    'DEFINE LCD_COMMANDUS 2000
    'DEFINE LCD_DATAUS 50

    TRISB=0

    LCDOUT $FE, 1
    LCDOUT "PIC - LCD Test "
    LCDOUT $FE, $C0

    STOP

    END
    Last edited by aggie007; - 2nd November 2007 at 00:56.

  2. #2


    Did you find this post helpful? Yes | No

    Default Contrast resistor

    With the LCDs I use, (Taiwanese) they will not work without a contrast resistor. This can be a single resistor about 10k (needs experiment) from the contrast pin to ground. Preferably use a pot with the ends between +5 and ground with the wiper to the contrast pin.

    Otherwise the screen will remain totally blank.

    HTH
    Brian

  3. #3
    Join Date
    Aug 2006
    Location
    Look, behind you.
    Posts
    2,818


    Did you find this post helpful? Yes | No

    Default

    Hello aggie007,
    BrianT is right on target with his post, I would also put a pause of about 1/2 second to 1 second before the first lcdout command to give the LCD time to initialise.
    If you do not believe in MAGIC, Consider how currency has value simply by printing it, and is then traded for real assets.
    .
    Gold is the money of kings, silver is the money of gentlemen, barter is the money of peasants - but debt is the money of slaves
    .
    There simply is no "Happy Spam" If you do it you will disappear from this forum.

  4. #4
    Join Date
    Jun 2006
    Location
    Greece
    Posts
    302


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by aggie007 View Post

    '******Setting up the LCD display******

    DEFINE LCD_DREG PORTB
    DEFINE LCD_DBIT 4
    DEFINE LCD_RSREG PORTB
    DEFINE LCD_RSBIT 7
    DEFINE LCD_EREG PORTB
    DEFINE LCD_EBIT 6
    DEFINE LCD_BITS 4
    DEFINE LCD_LINES 2
    DEFINE LCD_DBIT 4 Mean PORTB4-PORTB7
    and you use the same pins for RSBIT 7 and EBIT 6

  5. #5
    Join Date
    Nov 2007
    Posts
    13


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by BrianT View Post
    With the LCDs I use, (Taiwanese) they will not work without a contrast resistor. This can be a single resistor about 10k (needs experiment) from the contrast pin to ground. Preferably use a pot with the ends between +5 and ground with the wiper to the contrast pin.

    Otherwise the screen will remain totally blank.

    HTH
    Brian

    I am using a 20K pot which takes care of the contrast.

  6. #6
    Join Date
    Nov 2007
    Posts
    13


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by savnik View Post
    DEFINE LCD_DBIT 4 Mean PORTB4-PORTB7
    and you use the same pins for RSBIT 7 and EBIT 6

    Savnik,

    I didnt know that LCD_DBIT 4 means PORTB4-B7 ....I thought it just states the starting data bit for a 4 bit bus.....I was totally confused on this one !!

    Thanks for pointing it out....I'll try to make this work now !!!

  7. #7
    Join Date
    Sep 2004
    Location
    Mentor, Ohio
    Posts
    352


    Did you find this post helpful? Yes | No

    Smile

    Hi Aggie,

    There are more than enough posts on this forum that will help you work your way through just about anything you can think of. I'm not trying to chase you away but if you use the search facility on this forum you should have plenty of reading material that will get you going in no time. In fact I think there's almost enough here to write a book. What an idea!!!!! "USING PIC's WITH LCD DISPLAY". What an idea!!!!!

    HTH,

    BobK

  8. #8
    Join Date
    Nov 2007
    Posts
    13


    Did you find this post helpful? Yes | No

    Default

    I tried all those things mentioned above - 20K pot for contrast, etc, etc.

    But it still doesnt work !!

    The LCD lights up...but doesn't display anything. The PIC is working fine by itself, I tested it. But its not communicating with the LCD. I think the problem has something to do with the clock/oscillator.

    Do I need to connect an external resonator (20MHz) to the two OSC pins of the PIC ? If so, how do I do it ? Do I need to add something to my code ? How ?

    Please help.

Similar Threads

  1. Problem with PIC18F458 ADC code
    By minmin in forum mel PIC BASIC Pro
    Replies: 6
    Last Post: - 1st June 2011, 08:13
  2. Strange LCD problem with PIC16F876A
    By Glenn in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 15th October 2009, 08:56
  3. Making Program Code Space your playground...
    By Melanie in forum Code Examples
    Replies: 15
    Last Post: - 19th July 2008, 08:26
  4. problem with my code
    By civicgundam in forum mel PIC BASIC Pro
    Replies: 0
    Last Post: - 3rd February 2008, 01:52
  5. Apparent code size problem
    By eetech in forum mel PIC BASIC Pro
    Replies: 10
    Last Post: - 30th July 2007, 15:51

Members who have read this thread : 0

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts