LCD Troubles on 16F685


Closed Thread
Results 1 to 10 of 10
  1. #1
    Join Date
    Jan 2009
    Posts
    50

    Default LCD Troubles on 16F685

    I configured the code for a 16F628a and it worked fine.
    Now, I am trying to setup the same LCD for a 16F685.

    #CONFIG
    __config _INTRC_OSC_NOCLKOUT & _WDT_ON & _MCLRE_ON & _CP_OFF
    #ENDCONFIG

    high PortC.0 'LED on Port to check to see if PIC boots

    DEFINE OSC 4

    define LCD_DREG PORTA ' Data on PORTA
    define LCD_DBIT 0 ' Data starts on PORTA.0
    DEFINE LCD_RSREG PORTA ' RS on PORTA
    DEFINE LCD_RSBIT 4 ' RS on A4
    DEFINE LCD_EREG PORTA ' E on PORTA
    DEFINE LCD_EBIT 5 ' E on A5
    DEFINE LCD_BITS 4 ' LCD 4 bit mode
    DEFINE LCD_LINES 2 ' 2 line LCD display
    Define LCD_COMMANDUS 2000 ' Command Delay (uS)
    Define LCD_DATAUS 50 ' Data Delay (uS)

    Pause 500 ' Wait for LCD to startup
    mainloop:
    LCDOut $fe, 1 ' Clear LCD screen
    LCDOut "Hello"
    toggle portc.0
    pause 1000
    GoTo mainloop
    End

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


    Did you find this post helpful? Yes | No

    Default Re: LCD Troubles on 16F685

    I think that chip has ADC on PORTA. Turn ADC off.
    Dave
    Always wear safety glasses while programming.

  3. #3
    Join Date
    Jan 2009
    Posts
    50


    Did you find this post helpful? Yes | No

    Default Re: LCD Troubles on 16F685

    OK, how best to do that?

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


    Did you find this post helpful? Yes | No

    Default Re: LCD Troubles on 16F685

    Dave
    Always wear safety glasses while programming.

  5. #5
    Join Date
    Jan 2009
    Posts
    50


    Did you find this post helpful? Yes | No

    Default Re: LCD Troubles on 16F685

    Tried every bit of code to turn off ADC and CMC. Still the LCD just sits there and stares at me (!).

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


    Did you find this post helpful? Yes | No

    Default Re: LCD Troubles on 16F685

    I just looked at the datasheet and RA3 is the MCLR pin. You need to move things around so RA3 is not used as an output.
    Dave
    Always wear safety glasses while programming.

  7. #7
    Join Date
    Jan 2009
    Posts
    50


    Did you find this post helpful? Yes | No

    Default Re: LCD Troubles on 16F685

    Funny, I just looked at that! Thought maybe I could set a fuse to make this pin an output, but no avail.
    However, the LCD is now working!!!!
    Yay!
    Thanks very much. Now, my next task is to set an ADC and see if I can get that to work...
    Cheers.

  8. #8
    Join Date
    Jan 2009
    Posts
    50


    Did you find this post helpful? Yes | No

    Default Re: LCD Troubles on 16F685

    OK, next step is to initialize the ADC. Tried it but cannot go further. Would be nice to see a run-down of all the settings like ADSEL, for novice programmers like me to see exactly what these settings do. So here is the code that does not read ADC port AN0. Now, I use PortA.4 and PortA.5 so I use this:
    TrisA = 001111


    Code:
    #CONFIG
     __config _INTRC_OSC_NOCLKOUT & _WDT_ON & _MCLRE_ON & _CP_OFF
    #ENDCONFIG
    high portc.0
    DEFINE OSC 4
    DEFINE ADC_BITS 10       ' 10 bit A/D Conversion
    DEFINE ADC_CLOCK 3
    DEFINE ADC_SAMPLEUS 50   ' 50 uS A/D sample time
    VRCON  = 000000       ' Disable Comparator Voltage Reference
    ANSEL  = 000001       ' Set pin (AN0) to analog input, the rest to digital
    ADCON0 = 001001       ' Set up A/D converter - Right Just., VDD REF., CH 0, ON
    ADCON1 = 110000       ' Set up A/D Converter clock source to internal RC
    
    TrisA = 001111
               
    define LCD_DREG PORTB                      ' Data on PORTB
    define LCD_DBIT 4                          ' Data starts on PORTB.4
    DEFINE LCD_RSREG PORTA                     ' RS on PORTA
    DEFINE LCD_RSBIT 4                         ' RS on A4 
    DEFINE LCD_EREG PORTA                      ' E on PORTA
    DEFINE LCD_EBIT 5                          ' E on A5
    DEFINE LCD_BITS 4                          ' LCD 4 bit mode
    DEFINE LCD_LINES 2                         ' 2 line LCD display
    Define LCD_COMMANDUS 2000                  ' Command Delay (uS)
    Define LCD_DATAUS 50                       ' Data Delay (uS)
    adval var byte
     
           
    Pause 500       ' Wait for LCD to startup  
    mainloop: 
     ADCIN 0, adval
        LCDOut $fe, 1 ' Clear LCD screen
     LCDOut "Magnetic Pulser"
     'Charac 1234567890123456
        LCDOut $fe, $c0 'Jump to second line
        lcdout "Voltage:",  DEC adval
        toggle portc.0
        pause 100
     GoTo mainloop
    End
    Last edited by mackrackit; - 20th November 2011 at 10:09. Reason: Added Code Tags

  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 Troubles on 16F685

    This thread goes over some of it.
    http://www.picbasic.co.uk/forum/showthread.php?t=11947
    Dave
    Always wear safety glasses while programming.

  10. #10
    Join Date
    Jan 2009
    Posts
    50


    Did you find this post helpful? Yes | No

    Default Re: LCD Troubles on 16F685

    YAY!!! Sweet success!!!
    Thanks VERY much for walking me through this!!
    So good to see it working.
    Cheers!

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