LCD showing mostly jibberish on 16F716


Closed Thread
Results 1 to 22 of 22

Hybrid View

  1. #1
    Join Date
    Dec 2007
    Posts
    60

    Default LCD showing mostly jibberish on 16F716

    I've had a break from PIC's for a little so I'm a bit rusty, but I don't recall having this many issues in the past.

    Just trying to get an LCD to work first on my 16F716. I haven't used this pic before so might have some config wrong.

    B4-B7 goto DB4-DB7 on my 2-line LCD
    RW is held low VIA code, Enable and RS are on corresponding pins.

    The issue is that I get mostly jibberish all over the screen changing constantly, with glimpses of the text I'm trying to put there. I've mostly used 4-line LCD's before so don't even know if I have the addressing right, I dont' have a datasheet for this exact LCD
    I have tried fiddling the COMMANDUS and DATAUS values but they haven't had an effect, even without them there.


    Code:
    @ __CONFIG    _WDT_ON & _RC_OSC & _PWRTE_ON
    
    ' Define LCD registers and bits
    DEFINE  LCD_DREG        PORTB
    DEFINE  LCD_DBIT        4
    DEFINE  LCD_RSREG       PORTB
    DEFINE  LCD_RSBIT       3
    DEFINE  LCD_EREG        PORTB
    DEFINE  LCD_EBIT        1
    DEFINE  LCD_LINES       2
    
    DEFINE LCD_COMMANDUS 1500 	'defines the delay after LCDOUT statement 
    DEFINE LCD_DATAUS 44 		'delay in micro seconds
    
    TRISA = %11111
    TRISB = %00000000
    
    butdn           var porta.4
    butup           var porta.3
    butmode         var porta.2
    bail2           var porta.0
    bail3           var porta.1
    
    clutch          var portb.0
    lcdrw           var portb.2
    
    c               var word
    c = 0
    lcdrw = 0
    
    pause 150
    lcdout $fe,1
    pause 500
    Start: '************************************************************************   START
    c = c + 1
    lcdout $fe,1
    lcdout $fe,$00,"This is a test "
    lcdout $fe,$40,DEC c
    pause 500
    if c > 100 then
      c = 0
    endif
    GOTO start

  2. #2
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,521


    Did you find this post helpful? Yes | No

    Default Re: LCD showing mostly jibberish on 16F716

    Hi,
    I was going to suggest increasing the command and/or data delay considerably (say 5000us for command and 200 for data) just to see if it starts to work but perhaps you've already tried that while fiddling with the numbers?

    Apart from that it's the usual suspects like ADC and comparators but your device doesn't have any of that on the pins used so that can't be it. So, I think it's either a slow controller or a hardware problem like one of the datalines not reaching the controller.

    /Henrik.

  3. #3
    Join Date
    Dec 2007
    Posts
    60


    Did you find this post helpful? Yes | No

    Default Re: LCD showing mostly jibberish on 16F716

    Thanks for thereply.

    I haven't gone that high with the numbers so I'll try that in the morning. I made the pcb with a cnc machine, the socket is very close to the pic and the lcd is plugged straight into it. I don't think it's a connection problem but I will triple check. I put a 4 line lcd on and the same problem occurs.
    I am using the internal oscillator, could that be a cause?

  4. #4
    Join Date
    Oct 2009
    Posts
    583


    Did you find this post helpful? Yes | No

    Default Re: LCD showing mostly jibberish on 16F716

    If that's the full code, then should there not be an DEFINE OSC XX to let PBP know what frequency the PIC is running at.

    Have a look at my last post in this thread http://www.picbasic.co.uk/forum/showthread.php?t=20024

    You may need to change the config settings to match the chip you are using, but if it has an internal 4 Mhz clock then it should work without too much modifications

  5. #5
    Join Date
    Dec 2007
    Posts
    60


    Did you find this post helpful? Yes | No

    Default Re: LCD showing mostly jibberish on 16F716

    Scampy,

    That is interesting and a part of this PIC I don't fully understand. I've used PIC's with Internal OSC before, but quite a while ago and I don't remember being this confused about it.

    It seems unclear to me in the datasheet what frequency the internal OSC runs at and if any external components are required. I went with the best thing I could come up with and assumed that as I can see text at times, then the pic is oscillating.
    I did try DEFINE OSC 4 at the top earlier, but the problem still occurred.

  6. #6
    Join Date
    Oct 2009
    Posts
    583


    Did you find this post helpful? Yes | No

    Default Re: LCD showing mostly jibberish on 16F716

    Obviously by using the internal oscillator you can omit the external crystal shown in the easyPIC5 diagram. Some of the config lines in the code might need removing as you are using a different family of PICs than the one I used for testing. When I tried your code it compiled OK, but you have one line missing which could be the cause

    Code:
    DEFINE LCD_BITS  4               ' LCD bus size (4 or 8 bits)

  7. #7
    Join Date
    Dec 2007
    Posts
    60


    Did you find this post helpful? Yes | No

    Default Re: LCD showing mostly jibberish on 16F716

    A late night case of "I wonder if" has got me up. Set the command and data times up higher, still the same.
    Not real happy with a couple of the SMD solder pads for the pic. The leg has solder, and the pad has solder, but not convinced they are soldered together. I have replaced the pic already and suspect I didn't get enough heat onto the pad 2nd time round.

    Tomorrow I'll resolder at the workshop and cross my fingers.

  8. #8
    Join Date
    Oct 2009
    Posts
    583


    Did you find this post helpful? Yes | No

    Default Re: LCD showing mostly jibberish on 16F716

    I don't have a 16F716 to play with, but the following code works with an 18F 4580 running at 4mhz from its internal clock. LCD is on port B

    Code:
    ASM  
      __CONFIG    _CONFIG1H, _OSC_IRCIO7_1H ; _OSC_HSPLL_1H
      __CONFIG    _CONFIG2L, _PWRT_ON_2L  
      __CONFIG    _CONFIG2H, _WDT_ON_2H & _WDTPS_512_2H
      __CONFIG    _CONFIG3H, _PBADEN_OFF_3H
      __CONFIG    _CONFIG4L, _LVP_OFF_4L & _XINST_OFF_4L
    ENDASM
    
    DEFINE  OSC 4
    ADCON1 = $0F
    clear
    
    DEFINE LCD_DREG  PORTB           ' LCD Data port
    DEFINE LCD_DBIT  0               ' starting Data bit (0 or 4)
    DEFINE LCD_EREG  PORTB           ' LCD Enable port
    DEFINE LCD_EBIT  5               '     Enable bit  (on EasyPIC 5 LCD)
    DEFINE LCD_RSREG PORTB           ' LCD Register Select port
    DEFINE LCD_RSBIT 4               '     Register Select bit   (on EasyPIC 5 LCD)
    DEFINE LCD_BITS  4               ' LCD bus size (4 or 8 bits)
    DEFINE LCD_LINES 4               ' number of lines on LCD
    DEFINE LCD_COMMANDUS 2000        ' Command delay time in us 
    DEFINE LCD_DATAUS 50             ' Data delay time in us 
    
    LCDOUT $FE,1:FLAGS=0:PAUSE 250:LCDOUT $FE,1:PAUSE 250 ' Initialize LCD
    
    
    
    TRISA = %11111
    TRISB = %00000000
    
    butdn           var porta.4
    butup           var porta.3
    butmode         var porta.2
    bail2           var porta.0
    bail3           var porta.1
    
    clutch          var portb.0
    lcdrw           var portb.2
    
    c               var word
    c = 0
    lcdrw = 0
    
    pause 150
    lcdout $fe,1
    pause 500
    Start: '************************************************************************   START
    c = c + 1
    lcdout $fe,1
    lcdout $fe,$00,"This is a test ",DEC c
    pause 500
    if c > 100 then
      c = 0
    endif
    GOTO start
    I'm using an EasyPIC5 board which has the LCD wired as shown below



    You could try breadboarding the circuit to confirm the code etc is working. If so then the issue may well be with your PCB

Similar Threads

  1. Replies: 6
    Last Post: - 19th August 2013, 11:22
  2. 16f716
    By amit28 in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 28th November 2007, 17:56
  3. 16f716
    By mwhatley in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 3rd November 2006, 20:35
  4. Showing numbers in diffrent ways?
    By SuB-ZeRo in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 29th July 2005, 15:57
  5. Reading a Hex value from a Modem and showing it as Decimal..
    By Tom Gonser in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 16th March 2005, 17:58

Members who have read this thread : 1

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