Pic18f452 with 20x4 LCD Help


Closed Thread
Results 1 to 5 of 5
  1. #1
    Join Date
    Oct 2008
    Posts
    6

    Default Pic18f452 with 20x4 LCD Help

    Hi I am trying to initialize a CFA2004ATMIJP 20x4 LCD using a Pic18f452 @ 10MHz with PicBasic Pro. After compiling and uploading the hex file the screen stays blank. I have a 10K pot on VO and have it at around 4.2V. The LCD backlight is lit and I have used this code for an 8x2 Optrex LCD with no problems. The only modifications to the code for this LCD are setting the amount of lines to 4 lines instead of 2, and using different DDRAM Addresses such as 0x00, 0x40, 0x14, 0x54 for the LCDOUT commands. Can anyone see where I am going wrong? Thanks!

    I have verified with my dmm that all of the connections to the lcd and the pic are good and there are no shorts.

    0.1uF cap acrosss (Vss and Vdd)

    Vss = Gnd
    Vdd = 4.96V
    Vo = 4.2V
    RS = PORTE.0
    R/W = Gnd
    E = PORTE.1

    DB4 = PORTD.4
    DB5 = PORTD.5
    DB6 = PORTD.6
    DB7 = PORTD.7

    The Code
    ===========================

    ' PicBasic program to demonstrate operation of an LCD in 4-bit mode
    '

    DEFINE OSC 10

    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_COMMANDUS 2000
    DEFINE LCD_LINES 4
    DEFINE LCD_DATAUS 50


    'Force LCD init
    FLAGS=0
    Lcdout $fe, 1 'Clear LCD screen
    'LCD set-up time
    PAUSE 2000
    Lcdout $fe, 1 'Clear LCD screen


    ASM

    MOVLF macro literal,dest
    movlw literal
    movwf dest
    endm

    Initial
    MOVLF B'10001110',ADCON1 ;Enable PORTA & PORTE digital I/O pins
    MOVLF B'11100001',TRISA ;Set I/O for PORTA
    MOVLF B'11011100',TRISB ;Set I/O for PORTB
    MOVLF B'11010000',TRISC ;Set I/0 for PORTC
    MOVLF B'00001111',TRISD ;Set I/O for PORTD
    MOVLF B'00000000',TRISE ;Set I/O for PORTE
    MOVLF B'10001000',T0CON ;Set up Timer0 for a looptime of 10 ms
    MOVLF B'00010000',PORTA ;Turn off all four LEDs drssiven from PORTA
    ENDASM


    PORTA.4 = 0


    loop:
    LCDOUT $fe, $00, "LCD TEST" ' Display PULSVARs
    LCDOUT $fe, $40, "THIS SCREEN" ' Display PULSVARs
    LCDOUT $fe, $14, "IS 20 BY 4" ' Display PULSVARs
    LCDOUT $fe, $54, "CHARACTERS BIG" ' Display PULSVARs

    PAUSE 1000

    TOGGLE PORTA.4 ;Heartbeat LED

    Goto loop ' Do it forever

    End

  2. #2
    Join Date
    Oct 2004
    Location
    North Norfolk UK
    Posts
    146


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by djmachine View Post
    Hi I am trying to initialize a CFA2004ATMIJP 20x4 LCD using a Pic18f452 @ 10MHz with PicBasic Pro. After compiling and uploading the hex file the screen stays blank. I have a 10K pot on VO and have it at around 4.2V. The LCD backlight is lit and I have used this code for an 8x2 Optrex LCD with no problems. The only modifications to the code for this LCD are setting the amount of lines to 4 lines instead of 2, and using different DDRAM Addresses such as 0x00, 0x40, 0x14, 0x54 for the LCDOUT commands. Can anyone see where I am going wrong? Thanks!


    End
    Hi
    cannot find any datasheet for your lcd.

    but this may help:
    PBP supports
    LCD modules with a Hitachi 44780 controller or equivalent. These LCDs
    usually have a 14- or 16-pin single- or dual-row header at one edge.

    ______

  3. #3
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by djmachine View Post
    LCDOUT $fe, $00, "LCD TEST" ' Display PULSVARs
    LCDOUT $fe, $40, "THIS SCREEN" ' Display PULSVARs
    LCDOUT $fe, $14, "IS 20 BY 4" ' Display PULSVARs
    LCDOUT $fe, $54, "CHARACTERS BIG" ' Display PULSVARs
    Those are the correct addresses, but they have to be sent with a "Set DDRAM Address" command ($80).

    So $40 becomes $C0, and $14 is $94 etc..

    $80, $C0, $94, $D4
    <br>
    DT

  4. #4
    Join Date
    Oct 2008
    Posts
    6


    Did you find this post helpful? Yes | No

    Default

    I changed the addresses and also adjusted my Vo to 0.5V with reference to ground. But still nothing appears on the screen. Thanks for the replies.

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


    Did you find this post helpful? Yes | No

    Default

    Forget the LCD for now, use the same code but try a Serial communication test to your PC or use HPWM and measure the frequency.. what happen???
    Steve

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

Similar Threads

  1. 16f688 LCD what have I done wrong
    By spitfiredriver in forum mel PIC BASIC Pro
    Replies: 6
    Last Post: - 8th August 2009, 19:54
  2. Play with LCD on PICDEM
    By The IceMan in forum mel PIC BASIC
    Replies: 5
    Last Post: - 22nd August 2008, 16:56
  3. cant get my Lcd to work using Pic18f452
    By civicgundam in forum General
    Replies: 13
    Last Post: - 7th October 2007, 00:13
  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 20X4 connect with DS1820
    By jojokatada in forum mel PIC BASIC Pro
    Replies: 6
    Last Post: - 9th March 2005, 11:04

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