LCD & 18F1220

General discussion relating to the library modules supplied with the compiler

Moderators: David Barker, Jerry Messina

Post Reply
AndyO
Registered User
Registered User
Posts: 48
Joined: Sat Oct 27, 2007 7:08 pm
Location: Beijing, China

LCD & 18F1220

Post by AndyO » Sat Mar 01, 2008 2:58 pm

I'm a newbie to the world of PICs and Swordfish and would be grateful for any help anyone can offer.

I've been trying to get a character LCD to work with an 18F1220 on PORTA. The following code results in no LED lit or anything on the display:

Code: Select all

Device = 18F1220
Clock = 8

'LCD options
#option LCD_DATA = PORTA.0
#option LCD_RS = PORTA.6
#option LCD_EN = PORTA.7


Include "LCD.bas" 
Include "UTILS.BAS"


Dim LED As PORTB.0

'Set clock source to internal oscillator, I/O on RA6 & RA7
Config OSC = INTIO2

'Disable MCLR on Pin 4 (RA5)
Config MCLRE = OFF

'Set internal clock speed to 8MHz
OSCCON = $7F

'Turn off analogue functions
SetAllDigital


'Program Start

High(LED)

DelayMS(150)

LCD.Cls
LCD.WriteAt(1,1,"Hello World")

Repeat

       Toggle(LED)
       
       DelayMS(500)
       
Until FALSE
Commenting out the CLS and WriteAt lines still results in nothing. If I take out the Include "LCD.bas" line then I get a blinky LED so I think the PIC is working.

Tried the same code on an 18F4520 and it worked fine.

I'm sure I'm doing something stupid but I can't see it! Thanks in advance for any words of wisdom.

User avatar
David Barker
Swordfish Developer
Posts: 1214
Joined: Tue Oct 03, 2006 7:01 pm
Location: Saltburn by the Sea, UK
Contact:

Post by David Barker » Sat Mar 01, 2008 3:22 pm

Check out the SetAllDigital command, it should look something like this

http://www.sfcompiler.co.uk/wiki/pmwiki ... AllDigital

It depends on your compiler version. Also see

http://www.sfcompiler.co.uk/forum/viewtopic.php?t=142

with regard to using internal OSC - if you can, use an external until you get up and running.

AndyO
Registered User
Registered User
Posts: 48
Joined: Sat Oct 27, 2007 7:08 pm
Location: Beijing, China

Post by AndyO » Sat Mar 01, 2008 6:35 pm

Many thanks.
Putting the Config and OSCCON instructions into a module as you suggested did the trick - Top tip!

webrains
Posts: 1
Joined: Fri May 15, 2009 6:00 am
Location: India

LCD with 18f2620

Post by webrains » Fri May 15, 2009 6:24 am

Hi i am trying to connect LCD to 18f2620

I want to use following available pins pb4,5 and pc0,1 and pa2-5 to use a 16X2 LCD display

Can you please suggest me what settings i use in SetALLDigital and my program

regards

Post Reply