16f688 lcd connection


Closed Thread
Results 1 to 14 of 14

Hybrid View

  1. #1
    Join Date
    Dec 2010
    Posts
    48

    Arrow 16f688 lcd connection

    Hey all, I'm trying to write a program so I can use a LCM1602A lcd screen with a pic 16f688. Here are datasheets for both components:

    lcd - http://www.vintagecomputercables.com...02A-FL-YBW.pdf

    16f688 - http://ww1.microchip.com/downloads/e...Doc/41203B.pdf

    I believe the lcd is a HD44780 equivalent...but I'm not 100% sure. I have everything wired correctly to the best of my knowledge, but all I'm seeing on the screen are 16 black boxes across the top line. I'm using this website as guidance.

    http://embedded-lab.com/blog/?p=203

    I cannot take credit for this code, but this is the code I am using (how do I post my codes in the nice scrolling box?). Thanks to everyone for your help.
    Code:
    LED  var porta.2
    
    TRISC.0 = 0 '(pin 10) Blue Lcd Data bit 4
    TRISC.1 = 0 '(pin 9) White Lcd Data bit 5
    TRISC.2 = 0 '(pin 8) Green Lcd Data bit 6
    TRISC.3 = 0 '(pin 7) Orange Lcd Data bit 7
    TRISC.4 = 0 '(pin 6) Orange/Black Lcd Register select
    TRISC.5 = 0 '(pin 5) Blue/White Lcd Enable bit
    
    ' PIC Hardware Definitions (ie Pin-Out & Port Assignments)
    ANSEL = 0 ' all pins are digital
    CMCON0 = 7 ' turn off comparators
    ADCON0 = 0
    ADCON1 = 0
    
    'pin connection from pic chip to LCD
    '1 VDD 5V
    '2 OSC1 Crystal (internal 4MHz)
    '3 OSC2 Crystal (internal 4MHZ)
    '4 MCLR Pulled up
    '5 RC5 E LCD
    '6 RC4 RS LCD
    '7 RC3 DB7
    '8 RC2 DB6
    '9 RC1 DB5
    '10 RC0 DB4
    '11 RA2 LED pin
    '12 RA1 NC
    '13 RA0 NC
    '14 VSS Ov
    
    'Define LCD registers and bits
    DEFINE OSC 4 'Internal oscillator 4MHz
    DEFINE LCD_DREG PORTC 'Define PIC port used for LCD Data lines
    DEFINE LCD_DBIT 0 'LCD Data Starting Bit = Bit 0 or 4
    DEFINE LCD_EREG PORTC 'Define PIC port used for E line of LCD
    DEFINE LCD_EBIT 5 'Define Port pin used for E connection
    DEFINE LCD_RSREG PORTC 'Define PIC port used for RS line of LCD
    DEFINE LCD_RSBIT 4 'Define Port pin used for RS connection
    DEFINE LCD_BITS 4 'Define the 4 bit communication mode to LCD
    DEFINE LCD_LINES 2 'Define using a 2 line LCD
    DEFINE LCD_COMMANDUS 2000 'Define delay time between sending LCD commands
    DEFINE LCD_DATAUS 50 'Define delay time between data sent.
    
    Pause 500 ' Wait for LCD to startup
    
    loop: 
    
    high led
    pause 200
    low led
    
    Lcdout $fe, 1 ' Clear LCD screen
    Lcdout "Hello" ' Display Hello
    Pause 500 ' Wait .5 second
    
    Lcdout $fe, 1 ' Clear LCD screen
    Lcdout "World" 'Display World
    Pause 500 ' Wait .5 second
    
    Goto loop ' Do it forever
    Last edited by Archangel; - 9th December 2010 at 02:25.

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


    Did you find this post helpful? Yes | No

    Default

    Hello emerson,
    put the word code inside brackets [xxxx] and close with / code inside brackets [/xxxx] to enclose your code in a box. Check your contrast setting, I almost always just ground that pin, check your wiring for proper hookup AND for good connection. As I have not looked at the chips data sheet, check to be sure you have turned off ALL analog functions on the lcd's pins . . . are you sure ? Is your led flashing ? have you used bypass caps on the power at the PIC and LED ? Black boxes tell you LCD is alive more or less,so if led is flashing then so is PIC if not check your crystal and power connections first. A big ALSO, what config fuses are you using? The default ones? What are they ? Is the MCLR enabled ? do you have it pulled high ?
    A good time to add DEFINE OSC xx where xx is your selected value.
    Read and understand these threads please:
    http://www.picbasic.co.uk/forum/showthread.php?t=543
    http://www.picbasic.co.uk/forum/showthread.php?t=561
    They will reduce your headache pain considerably, (caused by pulling hair) and with some luck you will keep more than I did . . .
    hair that is . . .
    Many Many people ask WHY the authors of PIC books suggest the 16f84 chip, and I can answer that, it is because it has almost nothing to set up to get it to work, so beginners do not get frustrated so early on, your chip does have plenty of nice features which make getting started a bit more challenging, BUT you came to the right forum to get some help too.
    Hang in there, you are getting it.
    Last edited by Archangel; - 9th December 2010 at 03:25. Reason: add comment
    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
    Dec 2010
    Posts
    48


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Joe S. View Post
    Hello emerson,
    put the word code inside brackets [xxxx] and close with / code inside brackets [/xxxx] to enclose your code in a box. Check your contrast setting, I almost always just ground that pin, check your wiring for proper hookup AND for good connection. As I have not looked at the chips data sheet, check to be sure you have turned off ALL analog functions on the lcd's pins . . . are you sure ? Is your led flashing ? have you used bypass caps on the power at the PIC and LED ? Black boxes tell you LCD is alive more or less,so if led is flashing then so is PIC if not check your crystal and power connections first. A big ALSO, what config fuses are you using? The default ones? What are they ? Is the MCLR enabled ? do you have it pulled high ?
    A good time to add DEFINE OSC xx where xx is your selected value.
    Read and understand these threads please:
    http://www.picbasic.co.uk/forum/showthread.php?t=543
    http://www.picbasic.co.uk/forum/showthread.php?t=561
    They will reduce your headache pain considerably, (caused by pulling hair) and with some luck you will keep more than I did . . .
    hair that is . . .
    Many Many people ask WHY the authors of PIC books suggest the 16f84 chip, and I can answer that, it is because it has almost nothing to set up to get it to work, so beginners do not get frustrated so early on, your chip does have plenty of nice features which make getting started a bit more challenging, BUT you came to the right forum to get some help too.
    Hang in there, you are getting it.
    As of now I have the contrast pin tied to ground, the MCLR pin pulled high via 10K resistor, all of my wiring is good and has good connection, I have the bypass cap (0.1uf) on the power source (5V USB) and the LED is blinking. I'm reading the documents you sent and I'm understanding them little by little. Still trying to figure out how to set config fuses. Do I need to enable MCLR in the program or does pulling it high do the trick?

  4. #4
    Join Date
    Dec 2010
    Posts
    48


    Did you find this post helpful? Yes | No

    Default

    I'm having trouble understanding how to set the config fuses, could you give me an example or at least explain it to me? Thanks.
    Last edited by emerson; - 9th December 2010 at 05:07.

  5. #5
    Join Date
    Dec 2010
    Posts
    48


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by emerson View Post
    I'm having trouble understanding how to set the config fuses, could you give me an example or at least explain it to me? Thanks.
    This is what I have so far, and it compiles with no errors, but it still isn't doing the trick

    'Configuration Fuses
    @__EXTRC_OSC_NOCLKOUT
    @__WDT_OFF
    @__PWRTE_ON
    @__MCLRE_OFF
    @__BOREN_ON
    @__LVP_OFF
    @__CP_ALL
    @__DATA_CP_ON
    @__FCMEN_ON

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


    Did you find this post helpful? Yes | No

    Default

    You've not mentioned which version of PBP you are using. I think I'm correct in stating that you can't use the word loop as a label in vers 2.60. Things like "main" are probably OK.

    I've just searched through my PIC samples and don't have the one you are using. Is there any reason why you chose this PIC to use with an LCD as there are lots of other PICs that don't have the amount of functionality crammed into it as the 688.

    As you have stated that you have a flashing LED, this would suggest the code is running, but the LCD isn't responding... this suggests a timing issue. You have used what looks like an external config setting (@__EXTRC_OSC_NOCLKOUT) but in the code it states "internal 4Mhz". Are you using the internal 4Mhz timing or an external crystal, if internal then that fuse should be something like @_INTRC_OSC_NOCLKOUT.

    It's also worth posting up your schematic of how you have the hardware set up

Members who have read this thread : 1

You do not have permission to view the list of names.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts