20x4 LCD and P18F2680


Closed Thread
Results 1 to 10 of 10
  1. #1
    Join Date
    Aug 2005
    Posts
    20

    Question 20x4 LCD and P18F2680

    Hi!
    CODE:

    DEFINE LCD_DREG PORTB
    DEFINE LCD_DBIT 4
    DEFINE LCD_RSREG PORTB
    DEFINE LCD_RSBIT 2
    DEFINE LCD_EREG PORTB
    DEFINE LCD_EBIT 3
    DEFINE LCB_BITS 4
    DEFINE LCD_LINES 4
    DEFINE LCD_COMMANDUS 2000
    DEFINE LCD_DATAUS 40

    @ __CONFIG _CONFIG1H, _OSC_HS_1H & _FCMENB_ON_1H & _IESOB_ON_1H
    @ __CONFIG _CONFIG2L, _BOR_OFF_2L & _PWRT_OFF_2L '& _BORV_42_2L
    @ __CONFIG _CONFIG2H, _WDT_ON_2H & _WDTPS_128_2H
    @ __CONFIG _CONFIG3H, _MCLRE_ON_3H & _PBADEN_OFF_3H
    @ __CONFIG _CONFIG4L, _STVREN_ON_4L & _LVP_OFF_4L & _DEBUG_OFF_4L
    @ __CONFIG _CONFIG5L, _CP1_ON_5L & _CP0_ON_5L
    @ __CONFIG _CONFIG5H, _CPB_ON_5H & _CPD_ON_5H

    DEFINE OSC 20
    pause 4000
    loop:
    pause 1000
    lcdout $fe,1, "abcdefghilmnopqrstuv"
    lcdout $fe,$c0,"12345678912345678912"
    lcdout $fe,$94,"abcdefghilmnopqrstuv"
    lcdout $fe,$d4,"98765432198765432198"
    pause 2000
    goto loop

    END

    This is my little code...The problem is that I see only abcdefgh on the first line and 12345678 on the second line.
    The program works without problem with a pic16f916...
    How can I solve this problem?

    Thanks to all!
    Last edited by microuser; - 3rd June 2006 at 13:38.

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


    Did you find this post helpful? Yes | No

    Default

    You're still lucky that something work
    Datasheet, Register 19-2: ADCON1
    ADCON1=$0F
    Steve

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

  3. #3
    Join Date
    Aug 2005
    Posts
    20


    Did you find this post helpful? Yes | No

    Default

    Thank you Mister e, but the problem persist
    I also tried with DBits on portA (setting the ADCON0.0 register to 0), but nothing...

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


    Did you find this post helpful? Yes | No

    Default

    ADCON0 have nothing to do with this.. ADCON1 and probably CMCON have something to do with PORTA

    Hehe Even if i doubt it cause you a problem...
    Code:
    DEFINE LCB_BITS 4
    there's a typo error. BTW 4 bit mode is the default, you can remove that line
    Steve

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

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


    Did you find this post helpful? Yes | No

    Default

    How about if your write to two last lines before? Problem is still the same?

    Can you add some Pauses between each of your LCDOUT to see what's happen?

    What happen when you increase the LCD_DATAUS value to let's say 200?
    Last edited by mister_e; - 3rd June 2006 at 22:09.
    Steve

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

  6. #6
    Join Date
    Aug 2005
    Posts
    20


    Did you find this post helpful? Yes | No

    Default

    Yes, problem is the same but after change my 20MHz osc configured in HS mode with a 10Mhz configured in HSPPL mode it works fine... but why?

    changed lines:
    DEFINE OSC 40
    @ __CONFIG _CONFIG1H, _OSC_HSPLL_1H & _FCMENB_ON_1H & _IESOB_ON_1H

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


    Did you find this post helpful? Yes | No

    Default

    Reuse the 20MHZ crystal and remove capacitor around. What happen?

    Keep wire as short as possible. It's often a ProtoBoard capacitance.
    Steve

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

  8. #8
    Join Date
    Aug 2005
    Posts
    20


    Did you find this post helpful? Yes | No

    Default

    I tried to reuse 20MHz crystal osc without capacitators, but the problem is the same! I would try with another type of 18F pic's series, but I haven't one! With 10MHz osc and ppl mode on all is ok

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


    Did you find this post helpful? Yes | No

    Default

    There's definately a hardware problem

    More than often caused by
    1. unsufficient PSU filtering
    2. Crystal located too far from the PIC
    3. messy/loose protoboard contact
    4. Spaghetti fashionned ProtoBoard wiring

    I remember few ProtoBoard where you had to use the Weedeater before seeing a single electronic part... "Sir why i have problem ?"
    Steve

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

  10. #10
    Join Date
    Aug 2005
    Posts
    20


    Did you find this post helpful? Yes | No

    Unhappy

    I solve the problem with lcd, but now I don't succeed to establish an rs232 communicaton
    I think that my problem is with the oscillator and it's configuration! Now i'm using a 10MHz OSC with 18pf cap. in ppl configuration.

    Please also note that the led blink every 4,3 sec!

    This is my code...

    INCLUDE "modedefs.bas"

    DEFINE OSC 40
    DEFINE HSER_RCSTA 90h
    DEFINE HSER_TXSTA 24h
    DEFINE HSER_BAUD 19200
    DEFINE HSER_SPBRG 129

    @ __CONFIG _CONFIG1H, _OSC_HSPLL_1H & _FCMENB_OFF_1H & _IESOB_OFF_1H
    @ __CONFIG _CONFIG2L, _BOR_OFF_2L & _PWRT_OFF_2L
    @ __CONFIG _CONFIG2H, _WDT_ON_2H & _WDTPS_128_2H
    @ __CONFIG _CONFIG3H, _MCLRE_ON_3H & _PBADEN_OFF_3H
    @ __CONFIG _CONFIG4L, _STVREN_ON_4L & _LVP_OFF_4L & _DEBUG_OFF_4L
    @ __CONFIG _CONFIG5L, _CP1_ON_5L & _CP0_ON_5L
    @ __CONFIG _CONFIG5H, _CPB_ON_5H & _CPD_ON_5H

    ADCON1=$0F

    LOOP:
    HIGH PORTB.1
    PAUSE 1000
    HSEROUT ["TEST TEST TEST TEST TEST"]
    LOW PORTB.1
    PAUSE 1000
    GOTO LOOP
    END

    I think that it look that this is my first attempt with 18F series

    Please help me to understand where is the mistake

    TO--->mister e <<Very thanks for the aid!<<

    Kindly Regards!

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