Strange LCD problem with PIC16F876A


Closed Thread
Results 1 to 4 of 4
  1. #1
    Join Date
    Sep 2008
    Location
    Stockholm
    Posts
    80

    Default Strange LCD problem with PIC16F876A

    Today I started to build a project with a variant of PIC I never used before, 16F876A, but since its the little brother of my old fauvorite pic 16F877A I didnt think it would be any problems..

    HOWEVER..

    I got LCD-problems, and they are so strange. ..To boil it down I wrote a short test program..

    Code:
    @ DEVICE PIC16F876A,HS_OSC,LVP_OFF,WDT_OFF,PROTECT_OFF
    
    DEFINE OSC 20	' Lets work at 20 MHz
    
    '	DEFINE LCD_DREG	PORTA				' Set LCD Data port
    '	DEFINE LCD_DBIT	0						' Set starting Data bit (0 or 4) if 4-bit bus
    '	DEFINE LCD_RSREG	PORTA			' Set LCD Register Select port
    '	DEFINE LCD_RSBIT	4					' Set LCD Register Select bit
    '	DEFINE LCD_EREG	PORTB				' Set LCD Enable port
    '	DEFINE LCD_EBIT	3						' Set LCD Enable bit
    '	DEFINE LCD_BITS	4						' Set LCD bus size (4 or 8 bits)
    '	DEFINE LCD_LINES	2					' Set number of lines on LCD
    '	DEFINE LCD_COMMANDUS	1500	' Set command delay time in us
    '	DEFINE LCD_DATAUS	44				' Set data delay time in us
    
     
    pause 2000	' Gracetime for the LCD
    
    Main:
    
    	toggle PORTB.5
    	LCDOUT $FE, 1, "Hello"
    	LCDOUT $FE, $C0, "World"
    	pause 2000
    	LCDOUT $FE, 1, "1234567890123456"
    	pause 500
    	LCDOUT $FE, 1, "ABCDEFGHIJKLMNOP"
    	pause 500
    	LCDOUT $FE, 1, "abcdefghijklmnop"
    	pause 500
    	
    	goto main:
    	
    End
    ..The result is:

    First the display says

    Hello
    World

    ..Waits 2 seconds and then

    34567890123456
    waits .5 sec
    CDEFGHIJKLMNOP
    waits .5 sec
    cdefghijklmnop
    waits .5 sec
    llo
    World

    ..and then continue..

    Why is it eating the two leading chars ? ..I tried the display on another breadboard with an
    16F877A, works perfectly fine..

    I tried to add all defines, and tweak some values (currently commented out in the code), no difference.

    Any ideas ?

  2. #2
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default

    Hi Glen,

    Try increasing LCD_COMMANDUS
    Code:
    DEFINE LCD_COMMANDUS 2000
    Most of the displays I have take at least 1.6mS to complete a clear screen.
    <br>
    DT

  3. #3
    Join Date
    Sep 2008
    Location
    Stockholm
    Posts
    80


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Darrel Taylor View Post

    Try increasing LCD_COMMANDUS
    Code:
    DEFINE LCD_COMMANDUS 2000
    Most of the displays I have take at least 1.6mS to complete a clear screen.
    <br>
    Yes, that fixed the problem.

    STRANGE.. I never had to change this value before ? I can't understand why the same
    test program works on the same display, with the same pins, at the same frequency on a 16F877A ?

    Well, as long as it works I'm happy thanks alot!

  4. #4
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,615


    Did you find this post helpful? Yes | No

    Lightbulb

    Hi,

    Melabs changed the default value from 2000 to 1500 with release 2.50 ... WHY ??? , Good question !!!

    note you also can avoid resetting the LCD for each printed line ...

    by using LCDOUT $FE,2 .... ( home command )

    or LCDOUT $FE, $80 ... ( beginning of first line )

    and overwrite the existing displayed characters.

    Alain
    ************************************************** ***********************
    Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
    ************************************************** ***********************
    IF there is the word "Problem" in your question ...
    certainly the answer is " RTFM " or " RTFDataSheet " !!!
    *****************************************

Similar Threads

  1. LCD problem with 16F628
    By ngeronikolos in forum mel PIC BASIC Pro
    Replies: 25
    Last Post: - 19th September 2016, 08:28
  2. Newbie? Problem with LCD
    By lew247 in forum mel PIC BASIC Pro
    Replies: 10
    Last Post: - 7th December 2009, 19:48
  3. LCD problem
    By Andre_Pretorius in forum General
    Replies: 8
    Last Post: - 27th January 2009, 15:47
  4. Play with LCD on PICDEM
    By The IceMan in forum mel PIC BASIC
    Replies: 5
    Last Post: - 22nd August 2008, 16:56
  5. LCD Problem
    By karenhornby in forum General
    Replies: 3
    Last Post: - 19th June 2008, 11:43

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