Problem with Newhaven LCD on 18LF66K80


Closed Thread
Results 1 to 8 of 8
  1. #1
    Join Date
    May 2014
    Location
    Stone, Staffordshire, UK
    Posts
    3

    Default Problem with Newhaven LCD on 18LF66K80

    Hello,

    I am having great difficulty getting a newhaven 20x4 LCD working on my 18LF66K80 in 4 bit mode. When using PORTA.0-3, once one bit of data is set, it gets unset before the next is set. I have temporary solved that by embedding assembler which achieves the same thing, however I am getting a persistent problem where the display just shows 2 rows of vertical lines.



    I also get similar results from using LCDOUT, where basically when I set all the bits suitably it "just doesn't work" with similar effects to above.

    I am confident with the wiring as we have another PIC with the same code written in C (albeit 8bit) working perfectly.

    Code:
    D4-7 are on RA0-3 respectively
    RW is on RF3
    RS is on RF2
    E0 is on RA5
    The following are the defines I tried for LCDOUT.

    Code:
    DEFINE LCD_DREG PORTADEFINE LCD_DBIT 0
    DEFINE LCD_RSREG PORTF
    DEFINE LCD_RSBIT 2
    DEFINE LCD_REREG PORTF
    DEFINE LCD_RWBIT 3
    DEFINE LCD_EREG PORTA
    DEFINE LCD_EBIT 5
    DEFINE LCD_BITS 4
    DEFINE LCD_LINES 2
    DEFINE LCD_COMMANDUS 2100
    DEFINE LCD_DATAUS 500
    An example of the code I am using to display some text is below:

    Code:
    Main:
        LCDOut $fe,1:FLAGS=0:Pause 250
        LCDOUT "Hello World"
        pause 2000
    goto Main
    Any help getting to the bottom of this would be hugely appreciated!
    Last edited by KrisDouglas; - 30th May 2014 at 11:13.

  2. #2
    Join Date
    Mar 2003
    Location
    Commerce Michigan USA
    Posts
    1,166


    Did you find this post helpful? Yes | No

    Default Re: Problem with Newhaven LCD on 18LF66K80

    Kris, I would move the commands "FLAGS=0" and "PAUSE 250" to just above the MAIN loop. There is no reason to be resetting the display every loop. Also I would set the cursor command to be part of the LCDOUT statement as such: LCDOUT $fe.1,"Hello World". And 2100 us. seems a bit long for the command. I have never used anything more than 250 us. in the past and I have used all different kinds of lcd displays from different mfr's.
    Dave Purola,
    N8NTA
    EN82fn

  3. #3
    Join Date
    May 2014
    Location
    Stone, Staffordshire, UK
    Posts
    3


    Did you find this post helpful? Yes | No

    Default Re: Problem with Newhaven LCD on 18LF66K80

    Hello,

    Thanks for your reply, though we have messed with the command delays a lot just to see if we could get it working, I'll adjust it and try again now. When I connect it to the oscilloscope it seems that the enable line isn't going high for long enough when using LCDOUT which was interesting.

    I will try now and post the results.
    Kris Douglas

  4. #4
    Join Date
    Mar 2003
    Location
    Commerce Michigan USA
    Posts
    1,166


    Did you find this post helpful? Yes | No

    Default Re: Problem with Newhaven LCD on 18LF66K80

    One last thought Kris, I would like to see the direction registers for your ports as well as the the ANCON register values for the portA port F.
    Dave Purola,
    N8NTA
    EN82fn

  5. #5
    Join Date
    May 2014
    Location
    Stone, Staffordshire, UK
    Posts
    3


    Did you find this post helpful? Yes | No

    Default Re: Problem with Newhaven LCD on 18LF66K80

    Hello, my code for the LCD is as follows:

    Code:
    ' ------------------------------------------------------
    ' MiniCon Motherboard LCD Test
    ' Kris Douglas 23/05/14
    
    ' ------------------------------------------------------
    ' We will run at 64MHz once the PLL is started up
    Define OSC 64
    
    'LCD Definitions
    DEFINE LCD_DREG PORTA
    DEFINE LCD_DBIT 0
    DEFINE LCD_RSREG PORTF
    DEFINE LCD_RSBIT 2
    DEFINE LCD_REREG PORTF
    DEFINE LCD_RWBIT 3
    DEFINE LCD_EREG PORTA
    DEFINE LCD_EBIT 5
    DEFINE LCD_BITS 4
    DEFINE LCD_LINES 2
    DEFINE LCD_COMMANDUS 2100
    DEFINE LCD_DATAUS 500
    
    ' ------------------------------------------------------
    ' PIC18LF66K80 Configuration Bit Settings
    
    ' Basic source line config statements
    
    #CONFIG
        CONFIG RETEN = OFF
        CONFIG INTOSCSEL = HIGH
        CONFIG SOSCSEL = DIG
        CONFIG XINST = OFF
        CONFIG FOSC = INTIO2
        CONFIG PLLCFG = ON
        CONFIG FCMEN = OFF
        CONFIG IESO = OFF
        CONFIG PWRTEN = ON
        CONFIG BOREN = SBORDIS
        CONFIG BORV = 1
        CONFIG BORPWR = ZPBORMV
        CONFIG WDTEN = ON
        CONFIG WDTPS = 1048576
        CONFIG CANMX = PORTB
        CONFIG T0CKMX = PORTB
        CONFIG T3CKMX = PORTG
        CONFIG MSSPMSK = MSK7
        CONFIG MCLRE = ON
        CONFIG STVREN = ON
        CONFIG BBSIZ = BB2K
        CONFIG CP0 = OFF
        CONFIG CP1 = OFF
        CONFIG CP2 = OFF
        CONFIG CP3 = OFF
        CONFIG CPB = OFF
        CONFIG CPD = OFF
        CONFIG WRT0 = OFF
        CONFIG WRT1 = OFF
        CONFIG WRT2 = OFF
        CONFIG WRT3 = OFF
        CONFIG WRTC = OFF
        CONFIG WRTB = OFF
        CONFIG WRTD = OFF
        CONFIG EBTR0 = OFF
        CONFIG EBTR1 = OFF
        CONFIG EBTR2 = OFF
        CONFIG EBTR3 = OFF
        CONFIG EBTRB = OFF
    #ENDCONFIG
    
    ' ------------------------------------------------------
    ' Alias definitions
    
        'Alias the LED on the board
        localLed var PORTA.7
    
        'Alias the LCD control pins
        LCD_Backlight var PORTB.5
        LCD_E2 var PORTF.1
    
        'Alias the buzzer on the board
        buzzer var PORTC.1
    
        'Alias the watchdog
        mbWatchDog var PORTF.7
    
    ' ------------------------------------------------------
    ' Variables
    
        'LCD Variables
        lcdData var byte
        bla var byte
    
    ' ------------------------------------------------------
    ' Set Phase-Locked Loop to Enabled
    
        'OSCCON = OSCCON | %01110000
        'OSCTUNE = OSCTUNE | %01000000
    
    ' ------------------------------------------------------
    ' Port configuration
    
        'Port D needs setting to digital
        ADCON1 = %01101111
    
    ' ------------------------------------------------------
    ' Program code to flash LED and display text on LCD
    LCDOut $fe,1:FLAGS=0:Pause 250
    Main:
        LCDOUT $fe,1, "Hello World"
        pause 1000
    goto Main
    Kris Douglas

  6. #6
    Join Date
    Apr 2011
    Location
    Welches, Oregon
    Posts
    198


    Did you find this post helpful? Yes | No

    Default Re: Problem with Newhaven LCD on 18LF66K80

    I am NOT familiar with the chip you are using, but just yesterday I was near to pulling out my few remaining hairs before realizing that I had not set my TRIS registers to output. Is this necessary on the 18LF66K80?

  7. #7
    Join Date
    Jan 2005
    Location
    Montreal, Quebec, Canada
    Posts
    2,979


    Did you find this post helpful? Yes | No

    Default Re: Problem with Newhaven LCD on 18LF66K80

    Try adding this:
    http://www.picbasic.co.uk/forum/showthread.php?t=18529

    Then check the warnings during compile. It will tell you how to make all pins digital.

    You set port D to digital but I see nothing for port A.

    Robert

  8. #8
    Join Date
    Feb 2012
    Location
    PERTH AUSTRALIA
    Posts
    838


    Did you find this post helpful? Yes | No

    Default Re: Problem with Newhaven LCD on 18LF66K80

    i agree with robert , check port A config as a start point , as port a 0-5 are analog optional , also when connecting port at 64mhz i had some very bad results when not using the "LATA.x" commands for outputs , here Port A for the 18F67K22 , should be much the same

    Code:
    ' -------   Setup port A Variables  & directions  ----------
        ANCON0.0 = 1               ' Set PortA:0 Analog / Digital allocation - 0 = digital ,1 analog - ANSEL0
        ANCON0.1 = 1               ' Set PortA:1 Analog / Digital allocation - 0 = digital ,1 analog - ANSEL1
        ANCON0.2 = 1               ' Set PortA:2 Analog / Digital allocation - 0 = digital ,1 analog - ANSEL2
        ANCON0.3 = 1               ' Set PortA:3 Analog / Digital allocation - 0 = digital ,1 analog - ANSEL3
        ANCON0.4 = 1               ' Set PortA:5 Analog / Digital allocation - 0 = digital ,1 analog - ANSEL4 Set RA5 (AN4/ ANSEL4) to be analog input for V-Mon 
            
        TRISA =  %00101111         ' setup Port A input=1,output=0 for I/O pins , set input for RA0-RA3, RA5  
        PORTA  = %00101111         ' Clear Outputs

Similar Threads

  1. Problem with GOSUB/GOTO and Newhaven OLED question
    By Christopher4187 in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 12th April 2013, 11:24
  2. Newhaven Serial COG 2X16 LCD
    By Neosec in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 20th March 2013, 07:09
  3. Newhaven 4x40 LCD, issues!
    By MOUNTAIN747 in forum mel PIC BASIC Pro
    Replies: 27
    Last Post: - 18th October 2012, 23:23
  4. Replies: 36
    Last Post: - 14th March 2011, 19:38
  5. LCD Problem!
    By uaf5000 in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 20th May 2010, 00:06

Members who have read this thread : 0

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