LCD Module Lag on Initalize

General discussion relating to the library modules supplied with the compiler

Moderators: David Barker, Jerry Messina

Post Reply
animo3d
Posts: 24
Joined: Sun Sep 18, 2011 6:02 am
Location: Monterrey Mexico

LCD Module Lag on Initalize

Post by animo3d » Fri Jun 07, 2013 12:46 am

I have been working with Sworfish for some time now, used the LCD library several times and every time works fine, with the little annoyance of taking between 4 to 5 seconds to initalize after reset...

just a little example:

Code: Select all

Device = 18F46K20
Clock = 32


#option LCD_DATA = PORTB.0
#option LCD_RS = PORTB.5
#option LCD_EN = PORTB.4

Include "LCD.bas" 
    

 
Dim Led1 As PORTE.1
Dim a As Byte

OSCCON =$60
OSCTUNE.6 = 1
 
Output(Led1)

a=32
LCD.Cls
Repeat
  a=a+1
  Led1=1
  DelayMS(300)
  Led1=0
  DelayMS(300)
  LCD.WriteAt(1,1,a)
Until false
it works nice except for the lag... before now, the lag didn't bother me, but in a new application I need to get rid of the lag, I know it require some time for the LCD to initalize but 5 Seconds!!!

as anyone had this problem? is there a workaround?

thanks
Sergio

RKP
Registered User
Registered User
Posts: 82
Joined: Mon Oct 22, 2007 3:14 pm
Location: Maryland

Post by RKP » Fri Jun 07, 2013 1:11 pm

I an not sure which oscillator you are using.
Your code selects internal 8MHz osc. with PLL enabled but the 18F46K20 definition file defaults to FOSC = HS. You need to add Config FOSC= INTIO67 to your prgram.
EX.

Code: Select all

Device = 18F46K20 
Clock = 32 

Config FOSC= INTIO67  

#option LCD_DATA = PORTB.0 
#option LCD_RS = PORTB.5 
#option LCD_EN = PORTB.4 

Include "LCD.bas" 
    

  
Dim Led1 As PORTE.1 
Dim a As Byte 

OSCCON =$60 
OSCTUNE.6 = 1 
  
Output(Led1) 

a=32 
LCD.Cls 
Repeat 
  a=a+1 
  Led1=1 
  DelayMS(300) 
  Led1=0 
  DelayMS(300) 
  LCD.WriteAt(1,1,a) 
Until false 
Let us know if this works out better. Also how long were your 300mS delays?
If they were longer or shorter than expected, that is a clue the clock source does not match the clock setting.

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 » Fri Jun 07, 2013 3:15 pm

Most likely cause has been outlined by RKP. However, if you use a bootloader, remember it can sometimes add an additional 1-2 seconds to your start up time.

animo3d
Posts: 24
Joined: Sun Sep 18, 2011 6:02 am
Location: Monterrey Mexico

Post by animo3d » Sat Jun 08, 2013 5:05 pm

Im using the internal oscilator with PLL, and not using any bootloader, sorry I didn't post the complete config for this example:

Code: Select all

Config
    FOSC    = INTIO67,   // HS Oscillator
    FCMEN	= OFF,		// Failsafe Clock Monitor Disabled
    IESO	= OFF,		// Int/Ext Oscillator Switch Over Disabled
    PWRT	= OFF,		// Power Up Timer Disabled
    BOREN	= ON,		// Brownout Reset Disabled
    BORV    = 18,
    WDTEN   = OFF,		// Watchdog Timer Disabled
    MCLRE	= ON,		// MCLR Enabled
    WDTPS   = 256,          // 15000 x 4mS  = 60 seconds
    LVP     = OFF,          // Low_Voltage Programming
    PBADEN  = OFF,           // PORTB Digital  
    CP0     = ON, 
    CP1     = ON,
    CP2     = ON, 
    CP3     = ON, 
    CPB     = ON, 
    CPD     = ON
   
the oscilator is OK, the Dealyms are right on the spot, inclusive the UART library works well (I know the baudrate setting to work require the OSC to be correct)

could be that the LCD initalizes before I set the PLL?

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 Jun 08, 2013 5:11 pm

If using an internal oscillator, you need to check out this article

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

animo3d
Posts: 24
Joined: Sun Sep 18, 2011 6:02 am
Location: Monterrey Mexico

Post by animo3d » Mon Jun 10, 2013 6:01 am

Tanks David, that helps a lot!

Post Reply