PDA

View Full Version : 20x4 LCD and P18F2680



microuser
- 3rd June 2006, 09:40
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!

mister_e
- 3rd June 2006, 17:52
You're still lucky that something work :D
Datasheet, Register 19-2: ADCON1
ADCON1=$0F

microuser
- 3rd June 2006, 21:56
Thank you Mister e, but the problem persist :(
I also tried with DBits on portA (setting the ADCON0.0 register to 0), but nothing...

mister_e
- 3rd June 2006, 22:02
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...


DEFINE LCB_BITS 4

there's a typo error. BTW 4 bit mode is the default, you can remove that line

mister_e
- 3rd June 2006, 22:06
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?

microuser
- 4th June 2006, 11:45
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

mister_e
- 4th June 2006, 19:41
Reuse the 20MHZ crystal and remove capacitor around. What happen?

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

microuser
- 6th June 2006, 15:35
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 ;)

mister_e
- 6th June 2006, 23:29
There's definately a hardware problem

More than often caused by

unsufficient PSU filtering
Crystal located too far from the PIC
messy/loose protoboard contact
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 ?" :D

microuser
- 9th June 2006, 19:26
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 :D

Please help me to understand where is the mistake

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

Kindly Regards!