Menu

LCD problem with 16f684

Help
2007-01-19
2013-05-30
  • Nobody/Anonymous

    Drawing a blank on the LCD setup.  Guessing that maybe the multifunction pins are not initialized right or?  The compiler complains that symbols are not defined like:

    Error [113] : Symbol not previously defined (O).
    0084 1007      00228         bcf     TRISC,O
    0085 1087      00229         bcf     TRISC,1
    0086 1107      00230         bcf     TRISC,2
    0087 1187      00231         bcf     TRISC,3
    0088 1283      00232         banksel PORTA
    0089 1005      00233         bcf     PORTA,0
    008A 1085      00234         bcf     PORTA,1
    Error [113] : Symbol not previously defined (O).
    008B 1007      00235         bcf     PORTC,O
    008C 1487      00236         bsf     PORTC,1
    008D 1107      00237         bcf     PORTC,2
    008E 1187      00238         bcf     PORTC,3
    008F 1505      00239         bsf     PORTA,2

    The program:

    #chip 16F684, 8
    #config _CP_OFF & _CPD_OFF & _MCLRE_OFF  &   _BOD_OFF & _WDT_OFF & _PWRTE_ON & _INTRC_OSC_CLKOUT 

    #define LCD_IO 4
    #define LCD_DB4 PORTC.O
    #define LCD_DB5 PORTC.1
    #define LCD_DB6 PORTC.2
    #define LCD_DB7 PORTC.3
    #define LCD_RS PORTA.0
    #define LCD_RW PORTA.1
    #define LCD_Enable PORTA.2

    Main:
    Print "Hello World"
    wait 1 sec
    cls
    wait 1 sec
    Goto Main

    Regards,
    Kent

     
    • Hugh Considine

      Hugh Considine - 2007-01-20

      The problem is a simple typo. Replace:

      #define LCD_DB4 PORTC.O

      with:

      #define LCD_DB4 PORTC.0

      and it should work fine.

       
    • Nobody/Anonymous

      Thanks, it now compiles.  Just getting gibberish out on the lcd now tho.  The R/W line doesn't act quite right, as it has the effect of a reset.  Disconnecting the R/W line, and then re-inserting, gets the gibberish going.  Have double checked the port wiring, and even tried wiring backwards, just to make sure the data lines were set right.

      Regards,
      Kent

       
    • Sterling Youngman

      can you post the schematic for your ciruit? or email it to me at SterlingY@attglobal.net

      Thanks,

      Sterling

       
    • Nobody/Anonymous

      Sterling,
      Still no luck either.  I am using the PicKit 1 as a combo programmer and development board.  I have re-defined my ports so there is no conflict with the HV programming pins (i.e. RA.0, RA.1, RA.3, RA.4).  Also using the R/W pin, even tho only writes are used, seems the lcd.h files uses this so going with the flow.  And using the 16f684 with internal osc at 8Mhz, timing issues?

      #define LCD_IO 4
      #define LCD_DB4 PORTC.0  '==>pin 11
      #define LCD_DB5 PORTC.1  '==>pin 12
      #define LCD_DB6 PORTC.2  '==>pin 13
      #define LCD_DB7 PORTC.3  '==>pin 14
      #define LCD_RS PORTC.4   '==>pin 4
      #define LCD_RW PORTA.2  '==>pin 5
      #define LCD_Enable PORTC.5  '==>pin 6

      Also note that pin 1 to ground, pin 2 to +5V, and pin 3 is biased to ground with 4k7 resistor for my 4x20 display.  The correct contrast voltage can be found by connecting pin3 to the wiper of a 10k pot biased to ground.

      To my estimation, the lcd.h file is still broke, for the 4 bit mode anyways.  Anyone get this this to work?

      Regards,
      Kent

       
    • Sterling Youngman

      I wonder why you don't get an error when you define the LCD_IO as 4?

      You are also getting someting on your screen, even if it is gibberish.

      -Sterling

       
    • Nobody/Anonymous

      Maybe your lcd contrast pin3, because if nothing else, using the 10k pot should get you dark boxes?  Also disconnect the backlight led, if you are using it, until issues are resolved.

      Kent

       
    • Nobody/Anonymous

      A couple of other things:

      If you are going to use #chip 16F684, 8 then you must set the OSCCON register like so;
              OSCCON = OSCCON AND 112
      otherwise #chip 16f684, 4 works because that is the default 4mhz internal osc setting.

      Noticed this in my code _INTRC_OSC_CLKOUT , should probably be _INTRC_OSC_NOCLKOUT as this might affect RA.2 and RA.3.

      Also used these commands to make sure digital I/O;
           movlw    0x07       
          movwf    CMCON0        ;Comparator Off
          clrf    ANSEL        'A/D inputs to digital
          clrf    VRCON        'Vref Off 

      Regards,
      Kent

       
    • Sterling Youngman

      I'm getting a VERY faint display on the LCD. It isn't what I'm "printing" to the display, which is no surprise since you can't run the LCD routines in 4bit data mode.

      I guess we have to wait for the 4bit routine to get fixed, assuming that is the problem.

       
    • Nobody/Anonymous

      The cls, locate, and LCDInt commands don't appear to work either.  The blinking cursor ends up scrolling right off row one to row three, then off the screen, and over again.  The lcd controller/registers aren't being set up right.

      Maybe set up a case statement to detect type of lcd, say #define LCD_Size 216, or 420 which in turn allows word wrap or jump to next line?

      Kent

       
    • Sterling Youngman

      CHeck out this guy's site. The solution may be within these pages.

      He also has an LCD simulator, kind of interesting.

      http://www.geocities.com/dinceraydin/djlcdsim/djlcdsim.html

      -Sterling

       
    • Steve

      Steve - 2007-01-22

      Delete this:

      movlw 0x07 
      movwf CMCON0 ;Comparator Off
      clrf ANSEL 'A/D inputs to digital
      clrf VRCON 'Vref Off
      'clrf PORTA
      'clrf PORTC

      In your Main: subroutine, try the following for the 1st line:

      ADOFF

      That will turn off the a/d converter on port A.  If that doesn't work, try wiring your R/W line up to C.6 and recompile.

       
    • Nobody/Anonymous

      Thanks for the tips, much appreciated.  Used the ADOFF in main, and Switched RS, R/W, & E lines to many different locations with re-compilations.  The 16f684 does not have a full port (C.5 and A.5 is tops), so moving R/W line to C.6 not possible.  The LCD output is still not right.

      It's a mystery.  May try the LCD_IO 2 routine to see if that works.

      Kent 

       
    • Steve

      Steve - 2007-01-23

      Can you move the R/W, RS and E lines off port A to port B ?  I'm not familiar with the 16f684.

      The joys of LCDs !

       
    • Sterling Youngman

      The 16F684 does not have PORTB pins. A link to the datasheet: http://ww1.microchip.com/downloads/en/DeviceDoc/41202E.pdf

      It has PORTA0-5 and PORTC0-5

      -Sterling

       

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.