Need help on LCD


Closed Thread
Results 1 to 7 of 7

Hybrid View

  1. #1
    Join Date
    May 2007
    Location
    Area 71
    Posts
    52

    Default Need help on LCD

    I got my PIC 18F2550 blink an LED, but I cannot write to LCD
    LCD is working with other PIC, no hardware issue here
    PIC 18F2550, Xtal 10 Mhz

    This is my code
    Code:
    
    DEFINE OSC 10
    DEFINE LCD_DREG PORTB     ' LCD data port
    DEFINE LCD_DBIT 2         ' LCD data starting bit
    DEFINE LCD_RSREG PORTB    ' LCD register select port
    DEFINE LCD_RSBIT 0        ' LCD register select bit
    DEFINE LCD_EREG PORTB     ' LCD enable port
    DEFINE LCD_EBIT 1         ' LCD enable bit
    DEFINE LCD_BITS 4         ' LCD data bus size
    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
    Last edited by luminas; - 8th August 2008 at 04:50.

  2. #2
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    DEFINE LCD_DBIT 2 ' LCD data starting bit
    Re-Read your PBP manual concerning LCD_DBIT

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


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by luminas View Post
    I got my PIC 18F2550 blink an LED, but I cannot write to LCD
    LCD is working with other PIC, no hardware issue here
    PIC 18F2550, Xtal 10 Mhz

    This is my code
    Code:
    ASM
            __CONFIG    _CONFIG1L, _PLLDIV_10_1L & _CPUDIV_OSC1_PLL2_1L & _USBDIV_1_1L
            __CONFIG    _CONFIG1H, _FOSC_HS_1H
            __CONFIG    _CONFIG2L, _PWRT_ON_2L & _BOR_ON_2L & _VREGEN_OFF_2L
            __CONFIG    _CONFIG2H, _WDT_OFF_2H & _WDTPS_512_2H
            __CONFIG    _CONFIG3H, _PBADEN_On_3H & _MCLRE_ON_3H  & _CCP2MX_ON_3H
            __CONFIG    _CONFIG4L, _LVP_OFF_4L & _XINST_OFF_4L  & _DEBUG_OFF_4L
            
    ENDASM
    
    DEFINE OSC 10
    DEFINE LCD_DREG PORTB     ' LCD data port
    DEFINE LCD_DBIT 2         ' LCD data starting bit  <font color=red>not valid</font color>
    DEFINE LCD_RSREG PORTB    ' LCD register select port
    DEFINE LCD_RSBIT 0        ' LCD register select bit
    DEFINE LCD_EREG PORTB     ' LCD enable port
    DEFINE LCD_EBIT 1         ' LCD enable bit
    DEFINE LCD_BITS 4         ' LCD data bus size
    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
    clear
    porta = 0
    portb = 0
    portc = 0
    
    TRISA = %00000000               ' Set PORTA to all output
    TRISB = %00000000               ' Set PORTB to all output
    TRISC = %00000000               ' Set PORTC to all output
    
    main:
    
    LCDOUT $FE, 1  
    pause 100
    
    LCDOUT $FE, 1, "Hello "
    pause 100
    
    
    high porta.0
    pause 1000
    low porta.0
    pause 1000
    goto main
    D bit should be 0 or 4, you cannot use 2 - 5 directly this way, Darrel did do a workaround however . . .
    edit: Skimask was quicker on the draw . . .
    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
    May 2007
    Location
    Area 71
    Posts
    52


    Did you find this post helpful? Yes | No

    Default

    Thanks for your comments

    I changed the dbit to 4 , but nothing come out of the LCD , but LED is blinking
    This is my first time working with 18F2550, is there any other mistake I made?

    Code:
    ASM
            __CONFIG    _CONFIG1L, _PLLDIV_10_1L & _CPUDIV_OSC1_PLL2_1L & _USBDIV_1_1L
            __CONFIG    _CONFIG1H, _FOSC_HS_1H
            __CONFIG    _CONFIG2L, _PWRT_ON_2L & _BOR_ON_2L & _VREGEN_OFF_2L
            __CONFIG    _CONFIG2H, _WDT_OFF_2H & _WDTPS_512_2H
            __CONFIG    _CONFIG3H, _PBADEN_OFF_3H & _MCLRE_ON_3H  & _CCP2MX_ON_3H
            __CONFIG    _CONFIG4L, _LVP_OFF_4L & _XINST_OFF_4L  & _DEBUG_OFF_4L
            
    ENDASM
    
    DEFINE OSC 10
    
    
    DEFINE LCD_DREG PORTB     ' LCD data port
    DEFINE LCD_DBIT 4         ' LCD data starting bit
    DEFINE LCD_RSREG PORTB    ' LCD register select port
    DEFINE LCD_RSBIT 0        ' LCD register select bit
    DEFINE LCD_EREG PORTB     ' LCD enable port
    DEFINE LCD_EBIT 1         ' LCD enable bit
    DEFINE LCD_BITS 4         ' LCD data bus size
    DEFINE LCD_LINES 2        ' Number lines on LCD
    DEFINE LCD_COMMANDUS 1500 ' Command delay time in us
    DEFINE LCD_DATAUS 44      ' Data delay time in us
    clear
    porta = 0
    portb = 0
    portc = 0
    
    TRISA = %00000000               ' Set PORTA to all output
    TRISB = %00000000               ' Set PORTB to all output
    TRISC = %00000000               ' Set PORTC to all output
    
    
    main:
    LCDOUT $FE, 1  
    pause 100
    LCDOUT $FE, 1, "Hello "
    pause 100
    
    high porta.0
    pause 1000
    low porta.0
    pause 1000
    goto main

  5. #5
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by luminas View Post
    Thanks for your comments

    I changed the dbit to 4 , but nothing come out of the LCD , but LED is blinking
    This is my first time working with 18F2550, is there any other mistake I made?
    Change the D-Bit all you want...
    If you don't change the wiring that goes with it, it ain't gonna work...

  6. #6
    Join Date
    May 2007
    Location
    Area 71
    Posts
    52


    Did you find this post helpful? Yes | No

    Default Yes it works now

    I forgot to change the wiring hahaha......
    Now it works Thanks again..... have a nice day

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


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by skimask View Post
    Change the D-Bit all you want...
    If you don't change the wiring that goes with it, it ain't gonna work...
    You know, I almost suggested that, but I thought naw, that would be rude . . . DOH!
    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.

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 Problem
    By karenhornby in forum General
    Replies: 3
    Last Post: - 19th June 2008, 11:43
  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. LCD will not start
    By btaylor in forum mel PIC BASIC Pro
    Replies: 49
    Last Post: - 24th May 2007, 02:30

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