PIC16F684 + 8*2 LCD module


Closed Thread
Results 1 to 4 of 4
  1. #1
    xnihilo's Avatar
    xnihilo Guest

    Smile PIC16F684 + 8*2 LCD module

    Hi guys,

    I'm trying to use a Hitachi 44780 compatible LCD module with a pic16F684 but it does not work.

    All I see is a peristent row of black blocks.

    I connected:

    LCD to PIC
    ----------
    RS (pin 4) to PIC RA4
    E (pin 6) to PIC RA5
    R/W to GND
    D4 to RC0
    D5 to RC1
    D6 to RC2
    D7 to RC3
    D8 to RC4

    Of course I connected the Pin1 (vss) to GND and VDD to +5V and VO (pin3) to a trimmer to adjust the contrast.
    I connected pin 16 (backlight GND) to a transistor to PIC pin RC4 in order to control backlight in software. Pin 15 (+5V) is connected to +5V.

    My code is:

    ' Set LCD Data port
    DEFINE LCD_DREG PORTC

    ' Set starting Data bit (0 or 4) if 4-bit bus = portC bit 0 for LCD Data bit 4
    DEFINE LCD_DBIT 0

    ' Set LCD Register Select port
    DEFINE LCD_RSREG PORTA

    ' Set LCD Register Select bit
    DEFINE LCD_RSBIT 4

    ' Set LCD Enable port
    DEFINE LCD_EREG PORTA

    ' Set LCD Enable bit
    DEFINE LCD_EBIT 5

    ' Set LCD bus size (4 or 8 bits)
    DEFINE LCD_BITS 4

    ' Set number of lines on LCD
    DEFINE LCD_LINES 2

    ' Set command delay time in us
    DEFINE LCD_COMMANDUS 2000

    ' Set data delay time in us
    DEFINE LCD_DATAUS 50




    CLEAR



    CMCON0 = %00000111 'comparators OFF, val = 7

    ANSEL = %00000000 'choose digital i/o, val = 0


    OPTION_REG = %01111111 'enable internal porta weak pullups resistors

    WPUA = %010000 'enable weak pull ups for RS bit

    TRISA = %000000
    TRISC = %000000

    PORTA = %000000
    PORTC = %000000





    Pause 2000 ' Wait for LCD to startup


    START:

    FLAGS = 0

    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

    pause 2000

    HIGH PORTC.5 'turn on backlight
    LOW PORTC.5 'turn of backlight

    Goto loop ' Do it forever



    END











    CAN SOMEONE HELP ME PLEASE

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


    Did you find this post helpful? Yes | No

    Default

    Hello xnihilo
    shut down the analog stuff on port A and follow the instructions on the thread below.
    http://www.picbasic.co.uk/forum/showthread.php?t=543
    Doh . . . analog . . .so far down I missed it. As skimask always tells people, add a temporary blinky so as to know your PIC is working.
    Last edited by Archangel; - 5th March 2008 at 03:39.
    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.

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


    Did you find this post helpful? Yes | No

    Default

    Can you post a schematic?
    Looks like you have 7 connections from the display to the PIC.
    Should be 6.
    LCD to PIC
    ----------
    RS (pin 4) to PIC RA4
    E (pin 6) to PIC RA5
    R/W to GND
    D4 to RC0
    D5 to RC1
    D6 to RC2
    D7 to RC3
    D8 to RC4
    D8 is confusing me
    Dave
    Always wear safety glasses while programming.

  4. #4
    xnihilo's Avatar
    xnihilo Guest


    Did you find this post helpful? Yes | No

    Smile LCD and PIC16F684 - working

    Sorry I mistyped it I use 4 higher data bits of the LCD.

    I could make it work at last just before going to sleep yesterday.

    here is the code for a PIC16F684, hope it can be of help:

    ' Set LCD Data port
    DEFINE LCD_DREG PORTC

    ' Set starting Data bit (0 or 4) if 4-bit bus = portC bit 0 for LCD Data bit 4
    DEFINE LCD_DBIT 0

    ' Set LCD Register Select port
    DEFINE LCD_RSREG PORTA

    ' Set LCD Register Select bit
    DEFINE LCD_RSBIT 4

    ' Set LCD Enable port
    DEFINE LCD_EREG PORTA

    ' Set LCD Enable bit
    DEFINE LCD_EBIT 5

    ' Set LCD bus size (4 or 8 bits)
    DEFINE LCD_BITS 4

    ' Set number of lines on LCD
    DEFINE LCD_LINES 2

    ' Set command delay time in us
    DEFINE LCD_COMMANDUS 2000

    ' Set data delay time in us
    DEFINE LCD_DATAUS 50




    CLEAR



    CMCON0 = %00000111 'comparators OFF, val = 7

    ANSEL = %00000000 'choose digital i/o, val = 0


    OPTION_REG = %01111111 'enable internal porta weak pullups resistors

    WPUA = %010000 'enable weak pull ups for RS bit

    TRISA = %000000
    TRISC = %000000

    PORTA = %000000
    PORTC = %000000





    Pause 2000 ' Wait for LCD to startup


    START:

    FLAGS = 0

    loop:

    WPUA = %010000 'enable weak pull ups for RS bit


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

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

    pause 2000

    HIGH PORTC.5 'turn on backlight
    HIGH PORTC.4
    LOW PORTC.5 'turn of backlight
    LOW PORTC.4




    Goto loop ' Do it forever



    END

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, 20:54
  2. Play with LCD on PICDEM
    By The IceMan in forum mel PIC BASIC
    Replies: 5
    Last Post: - 22nd August 2008, 17:56
  3. Replies: 1
    Last Post: - 27th July 2008, 07:14
  4. PIC16F684 + LCD to use the 256bytes of EEPROM - HELP
    By xnihilo in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 7th March 2008, 15:19
  5. Need help with LCD number display.
    By Steve Matson in forum mel PIC BASIC
    Replies: 8
    Last Post: - 27th June 2007, 00:07

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