LCD not working with 18F4550


Closed Thread
Results 1 to 9 of 9
  1. #1
    Join Date
    Jan 2005
    Location
    Montreal, Quebec, Canada
    Posts
    2,640

    Question LCD not working with 18F4550

    Hi all,

    I started playing around with the 18F4550, read all the threads I could find on USB, triple-checked the configs, made sure DEFINES were in caps, but now I'm stumped on the most basic operation.

    - 18F4550 with 20MHz crystal
    - Lab X1 experimental board powered by wall adapter
    - PBP 2.60C
    - MicroCode Studio Plus v2.2.1.1
    - MPLAB MPASM

    ASM ; 18F4550, 20mhz crystal
    __CONFIG _CONFIG1L, _PLLDIV_5_1L & _CPUDIV_OSC1_PLL2_1L & _USBDIV_2_1L
    __CONFIG _CONFIG1H, _FOSC_HSPLL_HS_1H
    __CONFIG _CONFIG2L, _PWRT_OFF_2L & _BOR_ON_2L & _VREGEN_ON_2L
    __CONFIG _CONFIG2H, _WDT_OFF_2H
    __CONFIG _CONFIG3H, _CCP2MX_OFF_3H & _PBADEN_OFF_3H & _LPT1OSC_OFF_3H & _MCLRE_ON_3H
    __CONFIG _CONFIG4L, _STVREN_OFF_4L & _LVP_OFF_4L & _ICPRT_OFF_4L & _XINST_OFF_4L
    ENDASM
    DEFINE OSC 48
    DEFINE LCD_DREG PORTD
    DEFINE LCD_DBIT 4
    DEFINE LCD_RSREG PORTE
    DEFINE LCD_RSBIT 0
    DEFINE LCD_EREG PORTE
    DEFINE LCD_EBIT 1
    DEFINE LCD_BITS 4
    DEFINE LCD_LINES 2
    DEFINE LCD_COMMANDUS 2000
    DEFINE LCD_DATAUS 50

    TRISD = 0
    TRISE = 0

    PAUSE 1000
    LCDOUT $FE,1,"LabX1 18F4550"
    end
    Nothing comes out on the LCD.

    The LCD works fine, I used it for the Lab X1 examples I just added in Code Examples. I can get LEDs to blink back and forth, so I know the PIC can be programmed properly, but that's about it.

    (gets ready for point-and-laugh session)

    Robert
    Last edited by Demon; - 12th January 2012 at 06:51.

  2. #2
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,523


    Did you find this post helpful? Yes | No

    Default Re: LCD not working with 18F4550

    Hi Robert,
    Analog functions on PortE perhaps?

    Also, you say that you have a 20Mhz x-tal but then you DEFINE OSC 48, is that correct? I know the oscillator on the USB devices are a bit different and I'm not saying you've got it wrong but since it doesn't work perhaps it's worth looking into. Do a simple blink-a-led with a PAUSE 500 or whatever and verify that the timing looks OK.

    /Henrik.

  3. #3
    Join Date
    Apr 2007
    Location
    Pennsylvania, USA
    Posts
    158


    Did you find this post helpful? Yes | No

    Default Re: LCD not working with 18F4550

    You may need to initialize the display by sending a clear screen command, then pause 500ms or more before trying to write to it. I have had better luck with the displays doing this. Would also be worth checking the heart beat to verify osc settings like Henrik mentioned.
    Shawn

  4. #4
    Join Date
    Jan 2005
    Location
    Montreal, Quebec, Canada
    Posts
    2,640


    Did you find this post helpful? Yes | No

    Default Re: LCD not working with 18F4550

    Quote Originally Posted by HenrikOlsson View Post
    ...
    Analog functions on PortE perhaps?
    ...
    Hi Henrik,

    Tried ADCON1=7 with no success.


    Quote Originally Posted by HenrikOlsson View Post
    ...
    Also, you say that you have a 20Mhz x-tal but then you DEFINE OSC 48, is that correct? I know the oscillator on the USB devices are a bit different and I'm not saying you've got it wrong but since it doesn't work perhaps it's worth looking into.
    ...
    That's the way Darrel does it in his DT HID260 example.


    Quote Originally Posted by HenrikOlsson View Post
    ...
    Do a simple blink-a-led with a PAUSE 500 or whatever and verify that the timing looks OK.
    ...
    That was the first thing I did with this chip when I couldn't get the LCD working.
    Quote Originally Posted by Demon View Post
    ...
    The LCD works fine, I used it for the Lab X1 examples I just added in Code Examples. I can get LEDs to blink back and forth, so I know the PIC can be programmed properly, but that's about it.
    ...

    Quote Originally Posted by spcw1234 View Post
    ...
    You may need to initialize the display by sending a clear screen command, then pause 500ms or more before trying to write to it.
    ...
    Tried, still nothing on LCD.


    Current code:
    ASM
    __CONFIG _CONFIG1L, _PLLDIV_5_1L & _CPUDIV_OSC1_PLL2_1L & _USBDIV_2_1L
    __CONFIG _CONFIG1H, _FOSC_HSPLL_HS_1H
    __CONFIG _CONFIG2L, _PWRT_OFF_2L & _BOR_ON_2L & _VREGEN_ON_2L
    __CONFIG _CONFIG2H, _WDT_OFF_2H
    __CONFIG _CONFIG3H, _CCP2MX_OFF_3H & _PBADEN_OFF_3H & _LPT1OSC_OFF_3H & _MCLRE_ON_3H
    __CONFIG _CONFIG4L, _STVREN_OFF_4L & _LVP_OFF_4L & _ICPRT_OFF_4L & _XINST_OFF_4L
    ENDASM
    DEFINE OSC 48
    DEFINE LCD_DREG PORTD
    DEFINE LCD_DBIT 4
    DEFINE LCD_RSREG PORTE
    DEFINE LCD_RSBIT 0
    DEFINE LCD_EREG PORTE
    DEFINE LCD_EBIT 1
    DEFINE LCD_BITS 4
    DEFINE LCD_LINES 2
    DEFINE LCD_COMMANDUS 2000
    DEFINE LCD_DATAUS 50

    ADCON1 = 7
    TRISD = 0
    TRISE = 0

    WSLOOP var byte ' Loop counter

    PAUSE 1000
    LCDOUT $FE,1
    PAUSE 2000
    LCDOUT $FE,1,"LabX1 18F4550"

    PORTD = %00000001 ' Turn 1st LED on
    pause 100 ' Short delay

    CYCLE:
    for wsloop = 1 to 7 ' Turn on next LED from right to left
    PORTD = PORTD << 1
    pause 100
    next
    for wsloop = 1 to 7 ' Turn on next LED from left to right
    PORTD = PORTD >> 1
    pause 100
    next
    GOTO CYCLE
    END
    The LEDs blink back and forth but still no love from the LCD.

  5. #5
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default Re: LCD not working with 18F4550

    Tried ADCON1=7 with no success.
    Try 15. 7 only takes care of 8-12.

    DATA sheets are your friend.
    Please read the chips DATA sheet and make it happy
    Dave
    Always wear safety glasses while programming.

  6. #6
    Join Date
    Jan 2005
    Location
    Montreal, Quebec, Canada
    Posts
    2,640


    Did you find this post helpful? Yes | No

    Default Re: LCD not working with 18F4550

    Quote Originally Posted by mackrackit View Post
    Try 15. 7 only takes care of 8-12.

    DATA sheets are your friend.
    Please read the chips DATA sheet and make it happy

    GAAAAAAAAAAAA!!!!!

    That was it! You have no idea how much of that datasheet I went through, but I missed that part about ADCON1 being different. If it's one thing I learned from Steve, it's RTFM.

    Thanks!

  7. #7
    Join Date
    Aug 2007
    Posts
    9


    Did you find this post helpful? Yes | No

    Default Re: LCD not working with 18F4550

    try ADCON1 = %00001111

  8. #8
    Join Date
    Aug 2007
    Posts
    9


    Did you find this post helpful? Yes | No

    Default Re: LCD not working with 18F4550

    sorry and LCDOUT $fe,$80,"LabX1 18F4550"

  9. #9
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default Re: LCD not working with 18F4550

    Quote Originally Posted by selim View Post
    try ADCON1 = 001111
    He did and it fixed it. Did you not see that post?
    Dave
    Always wear safety glasses while programming.

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