I can not figure out an LCD issue


Closed Thread
Results 1 to 15 of 15

Hybrid View

  1. #1
    Join Date
    May 2009
    Location
    Montreal, QC, Canada
    Posts
    118

    Default I can not figure out an LCD issue

    Hi,
    I have been trying to figure this out for a couple of days now but no luck.

    I am using 16F627A
    At first I was using the internal osc with _INTOSC_OSC_NOCLKOUT and I was using the commented section bellow (Daryl's LCD_AnyPin) and I had DEFINE OSC 8 as any other value gave me a blank LCD.
    This setup displayed information well on the LCD but at the bottom of my code I have a PAUSE 5000 which I expected the second line to go blank after 5 seconds however it went blank after about 10 secs.

    I then added an 4 MHz external resonator, changed the fuse as bellow and tried different values for OSC but same results.

    So I restored my pbppic14.lib to its original value commented the LCD_AnyPin section and added the standard way as bellow but now I am just getting question marks on the LCD.

    So I guess I have 2 questions;
    1 -Why did I get the wrong timing in my first setup?
    2 - Why the standard way for LCD is not working whisle LCD_AnyPin did?

    If anyone can make my day, that would be great.

    Thanks

    Mike

    Code:
    @ __config _XT_OSC & _WDT_OFF & _MCLRE_ON & _LVP_OFF & _CP_OFF
    
    DEFINE OSC 4
    TRISB = 0                   ' Make PORTB all outputs
    CMCON = 7                   ' Disable comparator
    
    '- - - - LCD_AnyPin.pbp - - - - - - - - - - - - - - - - - -
    'LCD_DB4   VAR PORTB.0       ' Set port for 4 bits bus
    'LCD_DB5   VAR PORTB.1
    'LCD_DB6   VAR PORTB.2
    'LCD_DB7   VAR PORTB.3
    'LCD_RS    VAR PORTB.5       ' Set RS bit port
    'LCD_E     VAR PORTB.4       ' Set Enable bit port
    'LCD_Lines     CON 2         ' # of Lines on LCD,  1 or 2 (Note: use 2 for 4 lines)
    'LCD_DATAUS    CON 50        ' Data delay time in us 
    'LCD_COMMANDUS CON 2000      ' Command delay time in us 
    'INCLUDE "LCD_AnyPin.pbp"    ' Must go after LCD initialization 
    
    '- - - - Standard - - - - - - - - - - - - - - - - - -
    define LCD_DREG PORTB       ' Define LCD Data Port
    Define LCD_DBIT 0           ' Set starting data bit (0 or 4)
    Define LCD_RSREG PORTB      ' Set Register Select port
    Define LCD_RSBIT 5          ' Set RS bit
    Define LCD_EREG PORTB       ' Set Enable port
    Define LCD_EBIT 4           ' Set E bit
    Define LCD_BITS 4           ' Set bus size 
    Define LCD_LINES 2          ' Set number of lines on LCD
    Define LCD_COMMANDUS 2000   ' Set command delay time
    Define LCD_DATAUS 50        ' Set data delay time
    
    '- - - - start of program - - - - - - - - - - - - - - - - - -
    LCDOUT $FE,1                ' clear screen 
    LCDOUT $FE,$80,"LCD Prototype MJ"  
    
                                ' Use $Fe,$C0 to address the second line
    LCDOUT $FE,$C0,"Timer testing"  
    pause 5000
    LCDOUT $FE,$C0,"             "
    
    Start:                      ' Program starts here
                                
    
    goto start
                                
    end

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


    Did you find this post helpful? Yes | No

    Default

    _XT_OSC
    should be
    _HS_OSC
    with a resonator.

    LCD_DBIT 0
    change to
    LCD_DBIT 4

    Maybe...

    Why AnyPin worked? I have no idea.
    Dave
    Always wear safety glasses while programming.

  3. #3
    Join Date
    May 2009
    Location
    Montreal, QC, Canada
    Posts
    118


    Did you find this post helpful? Yes | No

    Default

    Thanks for the reply Mackrackit,

    Based on the datasheet _HS_OSC would be for 8 and 16 MHz but in my case I have 4 MHz.
    But I gave it a try and also setting LCD_DBIT 4 but I get no timing difference with the "AnyPin" and still zilch with other setup!

    I also tried FLAGS = 0 but still nothing

  4. #4
    malc-c's Avatar
    malc-c Guest


    Did you find this post helpful? Yes | No

    Default

    The following works for me using an EasyPIC5 board with the LCD on PORTB, 18F4550 with 20Mhz xtal (mainly as that's what I'm using for a current project and couldn't be bothered to change the PIC !)

    Code:
    ASM  ; 18F2550/4550, 20mhz crystal
       __CONFIG    _CONFIG1L, _PLLDIV_5_1L & _CPUDIV_OSC1_PLL2_1L & _USBDIV_2_1L
       __CONFIG    _CONFIG1H, _FOSC_HSPLL_HS_1H
       __CONFIG    _CONFIG2L, _PWRT_ON_2L & _BOR_OFF_2L & _VREGEN_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 48
    TRISB = 0                   ' Make PORTB all outputs
    CMCON = 7                   ' Disable comparator
    
    
    ;----[LCD definitions]------------------------------------------------------
    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 2              ' 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                ' clear screen 
    LCDOUT $FE,$80,"LCD Prototype MJ"  
    
                                ' Use $Fe,$C0 to address the second line
    LCDOUT $FE,$C0,"Timer testing"  
    pause 5000
    LCDOUT $FE,$C0,"             "
    
    Start:                      ' Program starts here
                                
    
    goto start
                                
    end
    Using DEFINE OSC 20 I had erroneous results on the LCD, so it's obviously a timing issue with your 4MHz resonator.

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


    Did you find this post helpful? Yes | No

    Default

    When you say resonator I think of a three pin thing with built in caps, HS works for that.
    If you are using a crystal then you may want to check the caps.

    Forget the LCD for a bit and figure out the timing problem by blinking an LED once per second.
    Dave
    Always wear safety glasses while programming.

  6. #6
    Join Date
    May 2009
    Location
    Montreal, QC, Canada
    Posts
    118


    Did you find this post helpful? Yes | No

    Default

    Thanks Malc-C for the reply but I am not exactly trying to make it work...
    Well yes I am trying to make it work but first I am trying to understand what is happening and what is my issue.

    Mackrackit,
    I am using a resonator (3 pins with caps incorporated) and double checked the datasheet and it does suggest _XT_OSC for a 4 MHz resonator.

    I followed your suggestion and I put a LED with puse 1000 and also it is taking 2 secs to blink. Now, I set DEFINE OSC 4 instead of 8 which brought down to 1 sec as I expected so I know that if i am using a 4 MHz crystal, I should be having DEFINE OSC 4. I could be wrong but I think this part is clear to me.

    So my questions are changing a bit and now I end up with:

    1 - Why does LCD_AnyPin only works with DEFINE OSC 8 although I have a 4 MHz crystal ?

    2 - Why the standard way for LCD is not working whisle LCD_AnyPin did even at 8 ?

    When I find out, I will never forget it!

    Mike

  7. #7
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,648


    Did you find this post helpful? Yes | No

    Question

    Quote Originally Posted by malc-c View Post
    The following works for me using an EasyPIC5 board with the LCD on PORTB, .

    Hi, Lili

    Me too with a 16F628 @ 8Mhz ... same board.
    "LCD on Anypin" mods implemented ... but not used here.

    may be the missing LCD Settling time @beginning of the program ???

    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 " !!!
    *****************************************

  8. #8
    Join Date
    May 2009
    Location
    Montreal, QC, Canada
    Posts
    118


    Did you find this post helpful? Yes | No

    Default

    Dave,
    I have tried
    DEFINE LCD_COMMANDUS 1000 and 4000
    DEFINE LCD_DATAUS 25 and 100
    with no aparent changes.

    Malcom,
    The display does work at 8 MHz with a 4 MHz resonator but the chip's timing is doubled and that is what I am trying to figure out. so a PAUSE 1000 will last 2 seconds instead of 1 second. The timing for this project is important because I want to build an ultrasound distance mesurement and so I have to time the echo received after sending an output burst of 40 KHz. I think I am far from my goal but I can't get started with the fun part untill I have figured out my issue with the timing problem.

    Alain,
    What did you mean by this?
    may be the missing LCD Settling time @beginning of the program ???
    For the record this is my hardware configuration and with an oscilloscope I see the 5V as pure DC 5.12V
    Attached Images Attached Images  

Similar Threads

  1. 16f688 LCD what have I done wrong
    By spitfiredriver in forum mel PIC BASIC Pro
    Replies: 6
    Last Post: - 8th August 2009, 19:54
  2. Play with LCD on PICDEM
    By The IceMan in forum mel PIC BASIC
    Replies: 5
    Last Post: - 22nd August 2008, 16:56
  3. LCD issue with EasyPIC5
    By manwolf in forum mel PIC BASIC Pro
    Replies: 12
    Last Post: - 15th June 2008, 09:17
  4. Need help with LCD number display.
    By Steve Matson in forum mel PIC BASIC
    Replies: 8
    Last Post: - 26th June 2007, 23:07
  5. LCD will not start
    By btaylor in forum mel PIC BASIC Pro
    Replies: 49
    Last Post: - 24th May 2007, 02:30

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