PIC Basic Code Understanding


Closed Thread
Results 1 to 15 of 15

Hybrid View

  1. #1
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,612


    Did you find this post helpful? Yes | No

    Default

    1 DEFINE LCD_DREG PORTD
    2 DEFINE LCD_DBIT 4
    This tells PBP that you have your LCD data-bus connected to PortD and that it "starts" at bit 4 of that port. In other word, the databus is connected to PortD.4-7 which means you are using it in 4-bit mode and that you'll also need:

    DEFINE LCD_BITS 4
    To tell PBP that you're using it in 4bit mode.

    3 DEFINE LCD_RSREG PORTE
    4 DEFINE LCD_RSBIT 0
    This tells PBP that the RegisterSelect of the LCD is connected to PORTE.0

    5 DEFINE LCD_EREG PORTE
    6 DEFINE LCD_EBIT 1
    This tells PBP that the Enable of the LCD is connected to PORTE.1

    If your PIC doesn't have a PORTE then change the DEFINEs so it matches what you have - that's what they are there for.

    /Henrik.

  2. #2
    malc-c's Avatar
    malc-c Guest


    Did you find this post helpful? Yes | No

    Default

    Using the attached image and the following code will better explain Henriks post with regards to using other ports



    Code:
    DEFINE LCD_DREG  PORTB          ' LCD Data port
    DEFINE LCD_DBIT  0              ' starting Data bit (0 or 4)
    DEFINE LCD_EREG  PORTB          ' LCD Enable port
    DEFINE LCD_EBIT  5              '     Enable bit  (on EasyPIC 5 LCD)
    DEFINE LCD_RSREG PORTB          ' LCD Register Select port
    DEFINE LCD_RSBIT 4              '     Register Select bit   (on EasyPIC 5 LCD)
    DEFINE LCD_BITS  4              ' LCD bus size (4 or 8 bits)
    DEFINE LCD_LINES 2              ' number of lines on LCD
    DEFINE LCD_COMMANDUS 2000       ' Command delay time in us 
    DEFINE LCD_DATAUS 50            ' Data delay time in us
    You can then use the following to initialise the LCD

    Code:
    LCDOUT $FE,1:FLAGS=0:PAUSE 250:LCDOUT $FE,1:PAUSE 250 ' Initialize LCD
    Last edited by malc-c; - 1st March 2010 at 20:19.

  3. #3
    Join Date
    May 2009
    Location
    Montreal, QC, Canada
    Posts
    118


    Did you find this post helpful? Yes | No

    Default

    Hi pr2don,

    I am just one week late but if you are still learning or trying to understand, this is where I learned how it works.

    http://iamsuhasm.wordpress.com/tutsproj/using-lcds/

    Mike

  4. #4


    Did you find this post helpful? Yes | No

    Default LCD initialization problem

    Quote Originally Posted by malc-c View Post
    Using the attached image and the following code will better explain Henriks post with regards to using other ports



    Code:
    DEFINE LCD_DREG  PORTB          ' LCD Data port
    DEFINE LCD_DBIT  0              ' starting Data bit (0 or 4)
    DEFINE LCD_EREG  PORTB          ' LCD Enable port
    DEFINE LCD_EBIT  5              '     Enable bit  (on EasyPIC 5 LCD)
    DEFINE LCD_RSREG PORTB          ' LCD Register Select port
    DEFINE LCD_RSBIT 4              '     Register Select bit   (on EasyPIC 5 LCD)
    DEFINE LCD_BITS  4              ' LCD bus size (4 or 8 bits)
    DEFINE LCD_LINES 2              ' number of lines on LCD
    DEFINE LCD_COMMANDUS 2000       ' Command delay time in us 
    DEFINE LCD_DATAUS 50            ' Data delay time in us
    You can then use the following to initialise the LCD

    Code:
    LCDOUT $FE,1:FLAGS=0:PAUSE 250:LCDOUT $FE,1:PAUSE 250 ' Initialize LCD

    Hello Sir,

    I am doing same things and working fine but sometimes when i power on the controller LCD doesn't display anything or it may display some garbage characters.

    I am using pic 16f876A controller with crystal freq 10Mhz

    LCD controller - Samsung KS0066

    any suggestions are well comed...

    thanks in advance

  5. #5
    malc-c's Avatar
    malc-c Guest


    Did you find this post helpful? Yes | No

    Default

    Occasionally I've experienced similar things after the initial re-programming. Resetting the PIC or power to my development board always works for me.

  6. #6
    Join Date
    Sep 2005
    Location
    Campbell, CA
    Posts
    1,107


    Did you find this post helpful? Yes | No

    Default

    You often have to pause about a half second before you write anything to the LCD. The displays are slow to get "started". The quarter-second pause in the previous example may not be quite enough.
    Charles Linquist

Similar Threads

  1. Making Program Code Space your playground...
    By Melanie in forum Code Examples
    Replies: 15
    Last Post: - 19th July 2008, 08:26
  2. pic Basic Pro 2.50a & debug statement
    By Phil Moore in forum mel PIC BASIC Pro
    Replies: 12
    Last Post: - 17th March 2008, 09:41
  3. PIC BASIC or PIC BASIC PRO
    By kirkmans in forum USB
    Replies: 3
    Last Post: - 20th April 2007, 00:52
  4. Replies: 5
    Last Post: - 17th January 2006, 19:26
  5. Help with MPASM and PIC Basic
    By johngb in forum mel PIC BASIC Pro
    Replies: 0
    Last Post: - 21st February 2003, 13:07

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