Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

getting LCD program to work?

Status
Not open for further replies.
Just installed Swordfish and tried this:
Code:
Device = 18F2525
Clock = 10
 
// some LCD options...
#option LCD_DATA = PORTB.0              // Assign the LCD connections
#option LCD_EN = PORTB.4                //
#option LCD_RS = PORTB.5                //
 
// import LCD library...
Include "LCD.bas"
Include "convert.bas"
Dim Variable As Word
 
// Start Of Program...
DelayMS(150)                            // Let the LCD warm up
LCD.Cls                                 // Clear the LCD screen
LCD.WriteAt(1,1,"Hello World")          // Send some text to the LCD
Variable = 0                            // Clear the "Variable" register
While True
    Inc(Variable)                       // Increment the "Var1" register
    // Convert to a string,
    //  and always display 5 characters   
    LCD.WriteAt(2,1,Convert.DecToStr(Variable,5))  
 
    DelayMS(1000)                       // Delay for 1 second                
Wend

Works!!! and counts up

Ensure the EN and RS lines are correct... i didnt and it wasnt working until i swapped the port numbers for them
 
TRISD all outputs?
I think this clears all the outputs?
Will check the EN and RS outputs
I wonder maybe not to worry but the code I posted is for a 4520 , I just droped the last 0. Shouldn't change anything??
Where is your TRISD?
 
your code should look like:
Code:
Device = 18F452
Clock = 10
 
// some LCD options...
#option LCD_DATA = PORTD.4              // Assign the LCD connections
#option LCD_EN = PORTD.3                //
#option LCD_RS = PORTD.2                //
 
// import LCD library...
Include "LCD.bas"
Include "convert.bas"
Dim Variable As Word
 
// Start Of Program...
DelayMS(150)                            // Let the LCD warm up
LCD.Cls                                 // Clear the LCD screen
LCD.WriteAt(1,1,"Hello World")          // Send some text to the LCD
Variable = 0                            // Clear the "Variable" register
While True
    Inc(Variable)                       // Increment the "Var1" register
    // Convert to a string,
    //  and always display 5 characters   
    LCD.WriteAt(2,1,Convert.DecToStr(Variable,5))  
 
    DelayMS(1000)                       // Delay for 1 second                
Wend
 
Last edited:
Check out Datasheet for 452 i think its in PSP mode...
try this code
Code:
Device = 18F452
Clock = 10
 
// some LCD options...
#option LCD_DATA = PORTD.4              // Assign the LCD connections
#option LCD_EN = PORTD.3                //
#option LCD_RS = PORTD.2                //
 
// import LCD library...
Include "LCD.bas"
Include "convert.bas"
Dim Variable As Word
 
// Start Of Program...
trise.4 = 0  //PSPMODE OFF for PORTD
trisd = 0    //TRISD = OUTPUTS
DelayMS(150)                            // Let the LCD warm up
LCD.Cls                                 // Clear the LCD screen
LCD.WriteAt(1,1,"Hello World")          // Send some text to the LCD
Variable = 0                            // Clear the "Variable" register
While True
    Inc(Variable)                       // Increment the "Var1" register
    // Convert to a string,
    //  and always display 5 characters   
    LCD.WriteAt(2,1,Convert.DecToStr(Variable,5))  
 
    DelayMS(1000)                       // Delay for 1 second                
Wend

try this code

I doubt thats the issue tho... is RW for LCD tied to GND?
 
Last edited:
You must be having a HARDWARE issue...
 

Attachments

  • Clipboard03..jpg
    Clipboard03..jpg
    476.2 KB · Views: 127
You're also missing the mandatory 0.1uF decoupling caps on the VDD / VSS pins. Check out the Unicorn schematic as it works with 2x16 LCDs fine.
 
I have all the caps in place.
After fiddeling with Pickit2 I ffind I must use the "autoinport hex and write" box as just selecting write does not seem to work.
I got the dang thing working after fumbling around with Pickit2 and Swordfish.
Metod is as follows- COMPILE& PROGRAM in swordfish
save file (for some reason it takes two saves before it shows up in Pickit2. It shows up in swordfish the first time??
Then erase PIC
AUTO IMPORT HEX then hit on
it works fine but need to find out several things
Swordfish dosn't seem to locate the PK@.cmd .exe file in loader compiler options
going to fiddle with pickit2 some more and try to figure out why this is so convulated.
 
I find that just hitting F10 (compile and program) the LCD lights up brifly. Then hit ON in Pickit2 and bingo!!
started fiddeling with the text just so I know I have actually changed the program.
Now waiting for modem hub w/ wireless so I can transfer files from one computer to the other without having to dump on to a CD
For some reason my computer #2 won't connect to the web via the USB. Hopefully the hub will work as planed.
Lots going on
 
At what speed will the internal oscillator run?
Would save a few parts. BUT have a chronograph I am planning on building that uses 20mhz (prescale the 10 mhz crystal) What ever pre scale is? Assume it basically multiplies the frequency?
 
It'll run at 8 speeds from about 31kHz to 8MHz, if your PIC has a PLL then it can multiply it x4 so 32MHz. If you're building a chronograph then IMO use a crystal that is easy to divide by a binary timer ie 9.8304MHz (yes it's a common frequency for crystals) or a 32768Hz watch crystal on TIMER1
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top