Running an LCD on different port


Closed Thread
Results 1 to 8 of 8
  1. #1
    malc-c's Avatar
    malc-c Guest

    Default Running an LCD on different port

    Quick question..(hopefully)

    In the PBP manual it details the use of PortB to interface with a 2 x 16 LCD.

    PBP assumes the LCD is connected to specific pins unless told otherwise. It assumes the LCD will be used with a 4-bit bus with data lines DB4 - DB7 connected to PICmicro PORTA.0 - PORTA.3, Register Select to PORTA.4 and Enable to PORTB.3.

    It is also preset to initialize the LCD to a 2 line display.

    To change this setup, place one or more of the following DEFINEs, all in upper-case, at the top of your PICBASIC PRO™ program:

    ' Set LCD Data port
    DEFINE LCD_DREG PORTB
    ' Set starting Data bit (0 or 4) if 4-bit bus
    DEFINE LCD_DBIT 4
    ' Set LCD Register Select port
    DEFINE LCD_RSREG PORTB
    If I wanted to use PORTC for the LCD display on a 16F873A PIC would the following work if the wiring was the same as shown in the manual (obviously substituting RA1 for RC1 etc)?


    ' Set LCD Data port
    DEFINE LCD_DREG PORTC
    ' Set starting Data bit (0 or 4) if 4-bit bus
    DEFINE LCD_DBIT 4
    ' Set LCD Register Select port
    DEFINE LCD_RSREG PORTC
    is there anything eles I would need to do to configure PORTC on the PIC other than TRISC=%00000000, for arguments sake disabling the rx / tx on ports RC7 and 6 ?
    Last edited by malc-c; - 17th December 2006 at 20:16.

  2. #2
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    Usually i place all LCD DEFINE's at the top even if i use the default pin assignement. It's easier to change later.
    Code:
    DEFINE LCD_DREG PORTC     ' LCD data port 
    DEFINE LCD_DBIT 0         ' LCD data starting bit 0 or 4 
    DEFINE LCD_RSREG PORTC    ' LCD register select port 
    DEFINE LCD_RSBIT 4        ' LCD register select bit 
    DEFINE LCD_EREG PORTC     ' LCD enable port 
    DEFINE LCD_EBIT 5         ' LCD enable bit 
    DEFINE LCD_BITS 4         ' LCD bus size 4 or 8 
    DEFINE LCD_LINES 2        ' Number lines on LCD 
    DEFINE LCD_COMMANDUS 2000 ' Command delay time in us 
    DEFINE LCD_DATAUS 50      ' Data delay time in us
    You don't need to disable the USART as he's already disable at POR.
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

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


    Did you find this post helpful? Yes | No

    Default

    Thanks steve, that make a lot of sence (Cuts and pastes code in readyness )

  4. #4
    Join Date
    Jun 2005
    Location
    Penang
    Posts
    40


    Did you find this post helpful? Yes | No

    Unhappy Problem Displaying dunno why?

    Hi,

    I got some problem with displaying 20 X 4 line LCD which the controller chip is HD 44780.Actually,when i programmed the chip according to the code below,the lcd is not working!.I even checked the PORTB pin and it seems not changing state?.But my board is working as i checked other programs (I2C,SPI) but this one is not working?.I feel weird.This program is actually sample program from Melabs itself.I wired the final 4 bit from lcd to PORTB.0 to PORTB.3 and the EBIT to to PORTD.7 and for sure RSBIT to PORTD.6.
    What is my mistake??Do i have to insert more code like LCD lines and delay???PLS HELP!


    DEFINE OSC 20



    DEFINE LCD_DREG PORTB
    DEFINE LCD_DBIT 4 ' 4 bit selected
    DEFINE LCD_RSREG PORTD
    DEFINE LCD_RSBIT 6 ' Reset Pin
    DEFINE LCD_EREG PORTD
    DEFINE LCD_EBIT 7 ' Enable Pin


    pause 500 ' Insert Delay for LCD to Power_Up.


    loop:


    Lcdout $fe, 1 ' Clear LCD screen
    Lcdout "Hello" ' Display Hello
    Pause 500 ' Wait .5 second

    Lcdout $fe, 1 ' Clear LCD screen
    Lcdout "World"
    Pause 500 ' Wait .5 second

    Goto loop ' Do it forever


    YOUR HELP KINDLY ACCEPTED

  5. #5
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    Change this
    Code:
    DEFINE LCD_DBIT 4 ' 4 bit selected
    to
    Code:
    DEFINE LCD_DBIT 0 ' Databit start at PORTB.0
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  6. #6
    Join Date
    Jun 2005
    Location
    Penang
    Posts
    40


    Did you find this post helpful? Yes | No

    Thumbs down I tried...

    Thanks for Instant reply but...


    Although i have changed the bit size from 4 to 0,it still remains the same.It does nothing.I even switch compiling from MPASM to standard compiler and it didn't show any effect at all.All the display line shows blank.


    It's a cheap LCD ( LM044L) and it's buggin me a lot.I still wonder why the PIC never do anything.I had no problem compiling other program but not this one.


    Any idea?.Pls help.Thanks a lot mister_e

  7. #7
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    Make sure the R/W pin is set to GND & play with the contrast Pot

    What happen?

    What is your PIC #?

    Could be the the config fuses as well, make sure you set HS_OSC and LVP_OFF

    Did you tied your unused LCD data pin (DB0, DB1, DB2, DB3) to gnd?

    And it's suppose to be a 4X20 LCD type.. you may try to add
    Code:
    DEFINE LCD_LINES 4
    Last edited by mister_e; - 18th December 2006 at 06:26.
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  8. #8
    Join Date
    Jun 2005
    Location
    Penang
    Posts
    40


    Did you find this post helpful? Yes | No

    Question Gonna give a try..

    I never tie the unused pin to ground as i belive it can be left floating?.Anyhow i will do it.I use PIC16F877.HS_OSC is set .I always set LVP_OFF (Low Voltage Programming) as it always does.Ok.I will insert : DEFINE LCD_LINES 4 :and see what happens.Not today but for sure tomorrow.



    Thanks a lot Steve.You are great.Hope you can help me tommorow too =>.




    NatureTech.
    Make thing simple,but not simpler.

Similar Threads

  1. Is this code not initialising the LCD properly?
    By Platypus in forum mel PIC BASIC Pro
    Replies: 8
    Last Post: - 30th January 2010, 19:14
  2. 16f688 LCD what have I done wrong
    By spitfiredriver in forum mel PIC BASIC Pro
    Replies: 6
    Last Post: - 8th August 2009, 19:54
  3. LCD R/S works on Port A but not Port B
    By TDonBass in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 10th February 2009, 12:41
  4. Need help with LCD number display.
    By Steve Matson in forum mel PIC BASIC
    Replies: 8
    Last Post: - 26th June 2007, 23:07
  5. Microcontroller with 2 way paging application problem
    By oneohthree in forum mel PIC BASIC Pro
    Replies: 30
    Last Post: - 20th April 2007, 17:27

Members who have read this thread : 1

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