16f88 can't get lcd to work


Closed Thread
Results 1 to 13 of 13
  1. #1
    Join Date
    Aug 2006
    Posts
    20

    Exclamation 16f88 can't get lcd to work

    Hi all,

    I've got a problem trying to display a simple message on an LCD using a PIC16F88. The problem, after much testing, seems to be the PAUSE command. It appears that the delay produced, even though in the code its 5sec, is much much much to small. So small infact that I think the LCD has little time initialise. The resulting text is very random both top and bottom lines.


    DEFINE OSC 4 ' XT osc
    DEFINE LCD_DREG PORTB
    DEFINE LCD_DBIT 4
    DEFINE LCD_RSREG PORTB
    DEFINE LCD_RSBIT 3
    DEFINE LCD_EREG PORTB
    DEFINE LCD_EBIT 2
    DEFINE LCD_BITS 4
    ' Set number of lines on LCD
    DEFINE LCD_LINES 2
    DEFINE LCD_COMMANDUS 2000
    ' Set data delay time in us
    DEFINE LCD_DATAUS 100

    ANSEL=0
    CMCON=7

    GOSUB DELAY
    Lcdout $fe, 1, "Hello" ' Display Hello
    GOSUB DELAY
    LCDOUT $FE,1,"John"
    END
    DELAY:PAUSE 5000
    RETURN

    I've tried everything including re-installing PBP/MCS. I've also compiled this code on a different machine;BUT, the LCD displays to quickly.

    To confirm all is OK I compiled this code for the 16f628, all was fine, there was indeed a 5 sec delay. Back to the 16f88, tried another fresh chip, same as before. Can't be the chip..

    I'm using PBP 2.47, MPLAB V7.31.




    Help most appreciated.

    John

  2. #2
    Join Date
    Aug 2006
    Posts
    20


    Did you find this post helpful? Yes | No

    Default

    I've searched the forum on the 16f88, however, it revealed no real answers to my delema.

    As far as I can tell the thing should work. I've set the fuses to:

    __config _CONFIG1, _HS_OSC & _WDT_ON & _LVP_OFF & _CP_OFF

    Still can't see why the PAUSE command of 5 sec appears as though its in the order of msec. I'm thinking it could be the programmer?? K149-BC

  3. #3
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by nicjo
    Hi all,

    I've got a problem trying to display a simple message on an LCD using a PIC16F88. The problem, after much testing, seems to be the PAUSE command. It appears that the delay produced, even though in the code its 5sec, is much much much to small. So small infact that I think the LCD has little time initialise. The resulting text is very random both top and bottom lines.


    DEFINE OSC 4 ' XT osc
    DEFINE LCD_DREG PORTB
    DEFINE LCD_DBIT 4
    DEFINE LCD_RSREG PORTB
    DEFINE LCD_RSBIT 3
    DEFINE LCD_EREG PORTB
    DEFINE LCD_EBIT 2
    DEFINE LCD_BITS 4
    ' Set number of lines on LCD
    DEFINE LCD_LINES 2
    DEFINE LCD_COMMANDUS 2000
    ' Set data delay time in us
    DEFINE LCD_DATAUS 100

    ANSEL=0
    CMCON=7

    GOSUB DELAY
    Lcdout $fe, 1, "Hello" ' Display Hello
    GOSUB DELAY
    LCDOUT $FE,1,"John"
    END


    DELAY:PAUSE 5000 <---------------

    DELAY:
    PAUSE 5000 <----- on a seperate line
    I don't know why it should make a difference. Ya never know...




    RETURN

    I've tried everything including re-installing PBP/MCS. I've also compiled this code on a different machine;BUT, the LCD displays to quickly.

    To confirm all is OK I compiled this code for the 16f628, all was fine, there was indeed a 5 sec delay. Back to the 16f88, tried another fresh chip, same as before. Can't be the chip..

    I'm using PBP 2.47, MPLAB V7.31.




    Help most appreciated.

    John



    See above......
    JDG

  4. #4
    Join Date
    Aug 2006
    Posts
    20


    Did you find this post helpful? Yes | No

    Default

    Thanks. I'm pretty sure that I've tried that. Code may have been slightly differnent but resulted in a new line for pause.

    scatching me head...

  5. #5
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    try....
    Code:
    PAUSE 2000
    Lcdout $fe, 1, "Hello" ' Display Hello
    Pause 2000
    LCDOUT $FE,1,"John"
    Spin: goto Spin
    if it doesn't work, you may need to double check your hardware, make sure your programmer program the config fuses, and make sure your MCLR pin is not floating.

    usual... 0.1uF cap close to the PIC, LCD R/W pin to GND and so on

    In general the HS_OSC fuse may work with 4MHZ crystal but also try with XT_OSC to see if it make any difference.
    Last edited by mister_e; - 10th December 2006 at 17:47.
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  6. #6
    Join Date
    Jun 2006
    Location
    Greece
    Posts
    302


    Did you find this post helpful? Yes | No

    Default

    try this
    Code:
        PAUSE 500
        
    loop:  
      
        Lcdout $fe, 1,"Hello" ' Display Hello
        Pause 2000
        Lcdout $fe, 1,"John"
        Pause 2000
        goto loop

  7. #7
    Join Date
    Aug 2006
    Location
    Look, behind you.
    Posts
    2,818


    Did you find this post helpful? Yes | No

    Default Give This A Try

    Hi John,
    Try this, I couldn't get the config fuses right for mpasm, but I was able to get them right for the default assembler. it should work keyword should.
    JS


    Code:
    @ DEVICE MCLR_OFF, XT_OSC, WDT_OFF, LVP_OFF, BOD_OFF, PWRT_ON, PROTECT_OFF
    DEFINE OSC 4 ' XT osc
    DEFINE LCD_DREG PORTB
    DEFINE LCD_DBIT 4
    DEFINE LCD_RSREG PORTB
    DEFINE LCD_RSBIT 3
    DEFINE LCD_EREG PORTB
    DEFINE LCD_EBIT 2
    DEFINE LCD_BITS 4
    ' Set number of lines on LCD
    DEFINE LCD_LINES 2
    DEFINE LCD_COMMANDUS 2000
    ' Set data delay time in us
    DEFINE LCD_DATAUS 100
    
    TRISB=%00000000                            ' all portb to output
    TRISA=%00000000                            ' all porta to output
    ADCON1 = 7 ' or ADCON1 = %00000111 'Disable A/D converter
    ANSEL=%00000000 ' set all analog pins to digital
    CMCON=7
    main
    pause 2000
    Lcdout $fe, 1, "Hello" ' Display Hello
    pause 1000 
    LCDOUT $FE,1,"John"
    goto main
    END
    Last edited by Archangel; - 12th December 2006 at 07:53.

  8. #8
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    Joe
    The MPASM config fuses are in the p16f88.inc file in the Microchip\MPASM suite folder
    Code:
    _CONFIG1                    EQU     H'2007'
    _CONFIG2                    EQU     H'2008'
    
    ;Configuration Byte 1 Options
    _CP_ALL                      EQU     H'1FFF'
    _CP_OFF	                     EQU     H'3FFF'
    _CCP1_RB0		    		 EQU     H'3FFF'
    _CCP1_RB3                    EQU     H'2FFF'
    _DEBUG_OFF                   EQU     H'3FFF'
    _DEBUG_ON                    EQU     H'37FF'
    _WRT_PROTECT_OFF             EQU     H'3FFF'	;No program memory write protection
    _WRT_PROTECT_256             EQU     H'3DFF'	;First 256 program memory protected
    _WRT_PROTECT_2048            EQU     H'3BFF'	;First 2048 program memory protected
    _WRT_PROTECT_ALL             EQU     H'39FF'	;All of program memory protected
    _CPD_ON                      EQU     H'3EFF'
    _CPD_OFF                     EQU     H'3FFF'
    _LVP_ON                      EQU     H'3FFF'
    _LVP_OFF                     EQU     H'3F7F'
    _BODEN_ON                    EQU     H'3FFF'
    _BODEN_OFF                   EQU     H'3FBF'
    _MCLR_ON		   		     EQU     H'3FFF'
    _MCLR_OFF                    EQU     H'3FDF'
    _PWRTE_OFF                   EQU     H'3FFF'
    _PWRTE_ON                    EQU     H'3FF7'
    _WDT_ON                      EQU     H'3FFF'
    _WDT_OFF                     EQU     H'3FFB'
    _EXTRC_CLKOUT		    	 EQU     H'3FFF'
    _EXTRC_IO		    		 EQU     H'3FFE'
    _INTRC_CLKOUT                EQU     H'3FFD'
    _INTRC_IO		    		 EQU     H'3FFC'
    _EXTCLK			    		 EQU     H'3FEF'
    _HS_OSC                      EQU     H'3FEE'
    _XT_OSC                      EQU     H'3FED'
    _LP_OSC                      EQU     H'3FEC'
    
    ;Configuration Byte 2 Options
    _IESO_ON                     EQU     H'3FFF'
    _IESO_OFF                    EQU     H'3FFD'
    _FCMEN_ON                    EQU     H'3FFF'
    _FCMEN_OFF                   EQU     H'3FFE'
    AND NEVER EVER END A PROGRAM WITH A SINGLE END STATEMENT... use STOP OR an endless loop

    Here we don't know if the user use an external or want to use the internal OSC...
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  9. #9
    Join Date
    Aug 2006
    Location
    Look, behind you.
    Posts
    2,818


    Did you find this post helpful? Yes | No

    Default you right boss!

    Quote Originally Posted by mister_e
    Joe . . .

    AND NEVER EVER END A PROGRAM WITH A SINGLE <h1>END</h1> STATEMENT... use STOP OR an endless loop

    ...
    Sorry about that mister_e, it got by me on the fourth paste, I had installed a goto main and then did a repaste and, oops left it out. As for mpasm config fuses . . . I kept getting errors using this format
    Code:
    @ __config _INTRC_OSC_NOCLKOUT & _WDT_ON & _PWRTE_ON & _MCLRE_OFF & _LVP_OFF & _BODEN_ON
    but not this exact code. I have edited above post.
    JS
    Last edited by Archangel; - 12th December 2006 at 07:54.

  10. #10
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    Yeah F88 is a bit like some 18F, try something around those bellow
    Code:
        '
        '    Pic Configuration
        '    =================
        '    Program Configuration Register 1
        @	__CONFIG    _CONFIG1, _CP_OFF & _CCP1_RB0 & _DEBUG_OFF & _WRT_PROTECT_OFF & _CPD_OFF & _LVP_OFF & _BODEN_ON & _MCLR_OFF & _PWRTE_ON & _WDT_OFF & _INTRC_IO		    		 
    
        '    Program Configuration Register 2
        @   __CONFIG    _CONFIG2, _IESO_OFF & _FCMEN_OFF
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  11. #11
    Join Date
    Aug 2006
    Location
    Look, behind you.
    Posts
    2,818


    Did you find this post helpful? Yes | No

    Default 16f88

    Hi Mister_e,
    The 16F88 seems to be extra labor intensive and not suitable for newbies, as it has so many registers that require you to set and other little quirks, there are several open posts this month by people (like myself) who are a little short on experience, that are having trouble with this device. I think they would do better with a 16F628a / 648a or 16F876 / 877 etc. At least until they get their sealegs.

  12. #12
    Join Date
    Feb 2003
    Posts
    432


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Joe S.
    Hi Mister_e,
    The 16F88 seems to be extra labor intensive and not suitable for newbies, as it has so many registers that require you to set and other little quirks, there are several open posts this month by people (like myself) who are a little short on experience, that are having trouble with this device. I think they would do better with a 16F628a / 648a or 16F876 / 877 etc. At least until they get their sealegs.
    To some extent that comment may be true but as the 16F88 is so versatile you can use it for many different projects so will quickly learn its quirks.

    I was using 16F628 for 18pin projects and 16F877 for 40 pin projects.

    I am now using 16F88 and 18F452.

    My 40 pin project outgrew the capabilities of the 877 and my reason for getting started with the F88 was because it can be bootloaded. A real boon for developing code
    Keith

    www.diyha.co.uk
    www.kat5.tv

  13. #13
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    well well well... there's always a new device... so there's always a new challenge (sort of) or problem.

    F88 is probably the new F628(a) for those doing the BIG JUMP from an F84(a). just do a search with 16F628, you'll be surprised how much time me and other repeat CMCON=7

    I also appreciate the F88 and it's like all firsts experience... the first time it doesn't work... You have to learn from it. and...read the datasheet A.K.A TFM (The Fabulous Manual)

    I don't really have a favourite one... from 10F to 18F and some DsPIC when really needed.
    Last edited by mister_e; - 13th December 2006 at 02:23.
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

Similar Threads

  1. Play with LCD on PICDEM
    By The IceMan in forum mel PIC BASIC
    Replies: 5
    Last Post: - 22nd August 2008, 16:56
  2. Need help with LCD number display.
    By Steve Matson in forum mel PIC BASIC
    Replies: 8
    Last Post: - 26th June 2007, 23:07
  3. Why doesn't my code for 18f452 work on 18f252?
    By senojlr in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 23rd December 2005, 02:42
  4. Can't get LCD to work with 16F88
    By jswayze in forum mel PIC BASIC Pro
    Replies: 11
    Last Post: - 10th September 2004, 11:05
  5. 4 line LCD with 16F88
    By anj in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 7th February 2004, 09:06

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