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.

18F1320 timing issue w/ LCD

Status
Not open for further replies.

MrDEB

Well-Known Member
Got the LCD module working with an 18F452 but now trying to get an LCD to work with an 18F1320
Seeing how it operates I suspect something with my code as the "hello world" comes on after about 30 seconds but the seconds counter does not increment.
Being a newbi I am stumped but think its with using the internal occicilator?
Code:
// your main code would look like this
 
Device = 18F1320
Clock = 8 // 8MHz clock
Config OSC = INTIO2, WDT = OFF, LVP = OFF

 // LCD code
// some LCD options...
#option LCD_DATA = PORTB.0              // Assign the LCD connections
#option LCD_EN = PORTB.5                //
#option LCD_RS = PORTB.4                //
 
// import LCD library...
Include "LCD.bas"
Include "convert.bas"
Include "ADC.bas"
Dim Variable As Word
Dim ADVal 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
 
Thanks Bebe will give it a try. I kinda figured it was something to do with timing.
 
If you just add the line to your module it will still be very slow as it has to go through the LCD init routines before it executes you code. The way I get around this is to have a module called init.bas that is the first to be included. It contains,
Code:
Module init

OSCCON=$70

Mike.
 
Hi everyone, since he is using the internal oscillator,wouldnt it be better that he also check IOFS (OSCCON) to ensure that the oscillator is stable before he actually performs the task.
 
Status
Not open for further replies.

Latest threads

Back
Top