Long start time


Closed Thread
Results 1 to 11 of 11

Thread: Long start time

  1. #1
    Join Date
    Mar 2007
    Posts
    17

    Default Long start time

    Hi,

    I have a 44-pin demo board with a 18f4431 driving a Varitronix LCD display. After I push the program to the pic with a PicKit2.

    The problem is it takes 30-40 sec for the display to show the message. Code is below, is this normal? What have I screwed up?

    thanks

    t

    ' Define LCD registers and bits
    DEFINE LCD_DREG PORTB 'LCD data port
    DEFINE LCD_DBIT 0 'LCD data starting bit 0 or 4
    DEFINE LCD_BITS 4 'LCD bus size 4 or 8

    DEFINE LCD_LINES 2 'Number lines on LCD


    DEFINE LCD_RSREG PORTD 'LCD register select port
    DEFINE LCD_RSBIT 1 'LCD register select bit

    DEFINE LCD_RWREG PORTD 'LCD read/write port
    DEFINE LCD_RWBIT 2 'LCD read/write bit

    DEFINE LCD_EREG PORTD 'LCD enable port
    DEFINE LCD_EBIT 3 'LCD enable bit

    DEFINE LCD_COMMANDUS 2000 'Command delay time in us
    DEFINE LCD_DATAUS 50 'Data delay time in us

    TRISC = 0
    TRISB = 0
    TRISD = 0

    ANSEL0 = 0
    ANSEL1 = 0

    Low PORTD.1

    Low PortD.2
    Pause 500

    Lcdout $fe, 1

    loop:
    Lcdout $fe, $1, "Hello"
    Lcdout $fe, $c0, "World"

    Goto loop ' Do it forever
    End

  2. #2
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    I don't see any sort of oscillator configuration. PBP defaults to 4mhz. And I'd be wondering if your not running off the interal failsafe oscillator (37khz), 108 times slower. you've got a pause 500 before everything else starts running, .5 * 108 = about 54 seconds...the math doesn't quite work, but it's a possibility.

  3. #3
    Join Date
    Mar 2007
    Posts
    17


    Did you find this post helpful? Yes | No

    Default more results

    Okay, I added:

    DEFINE OSC 8 and added a PAUSE 10 (see below) in the loop: and another message so I toggle between the two.

    The message still takes ~ 2 sec to toggle. Another thing I've noticed is that the old program runs for some time before the new one 'kicks in'. I think I'm missing some basic principles here. Any help?

    Using the PicKit2 with the auto import and write feature to load the hex. I have used the <ctl>I -<ctl>w with the same results.

    As always, thanks.

    i = 0

    loop:
    if i = 1 then
    Lcdout $fe, $1, "Hello"
    Lcdout $fe, $c0, "World"
    i = 0
    else
    Lcdout $fe, $1, "Wiggles"
    Lcdout $fe, $c0, "is here!"
    i = 1
    endif
    pause 10
    Goto loop ' Do it forever
    Last edited by ttease; - 7th April 2007 at 14:43. Reason: add missing details and code

  4. #4
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by ttease View Post
    Okay, I added:

    DEFINE OSC 8 and added a PAUSE 10 (see below) in the loop: and another message so I toggle between the two.

    The message still takes ~ 2 sec to toggle. Another thing I've noticed is that the old program runs for some time before the new one 'kicks in'. I think I'm missing some basic principles here. Any help?

    Using the PicKit2 with the auto import and write feature to load the hex. I have used the <ctl>I -<ctl>w with the same results.

    As always, thanks.

    i = 0

    loop:
    if i = 1 then
    Lcdout $fe, $1, "Hello"
    Lcdout $fe, $c0, "World"
    i = 0
    else
    Lcdout $fe, $1, "Wiggles"
    Lcdout $fe, $c0, "is here!"
    i = 1
    endif
    pause 10
    Goto loop ' Do it forever
    Same thing applies as my other post. Your program is expecting 8mhz. If the PIC is actually running from the internal failsafe, oscillator then it's probably running about 37khz. That's roughly 216 times slower than what you are expecting. 10ms of pause * 216 = a bit over 2 seconds.
    Something wrong with your oscillator somewhere I'm betting...

  5. #5
    Join Date
    Aug 2006
    Location
    Look, behind you.
    Posts
    2,818


    Did you find this post helpful? Yes | No

    Default Config Fuses

    Have you set the config fuses? Which assembler are you using, MPASM or the default assembler ?
    If you do not believe in MAGIC, Consider how currency has value simply by printing it, and is then traded for real assets.
    .
    Gold is the money of kings, silver is the money of gentlemen, barter is the money of peasants - but debt is the money of slaves
    .
    There simply is no "Happy Spam" If you do it you will disappear from this forum.

  6. #6
    Join Date
    Mar 2007
    Posts
    17


    Did you find this post helpful? Yes | No

    Default Config fuses

    Hi,

    Using MPMASM, not sure how to use the 'default assembler'. I just found the PIC18EXT.bas file and defs. I can set the clock and other SFR values and test.

    BTW, do all suppor the OPTIONS_REG def. The only thing in the ds with OPTION_REG is TIMER0, how come the PORTB pull ups are in this?

    Where would I get this information from?

    thanks

    t
    Last edited by ttease; - 8th April 2007 at 03:21.

  7. #7
    Join Date
    Mar 2007
    Posts
    17


    Did you find this post helpful? Yes | No

    Default CONFIG fuses

    Verified, using MPASM 5.1.

    If I want to config the PIC to run at 8mHz, I thought it was simply this:

    DEFINE OSC 8

    Is this incorrect?

    t
    Last edited by ttease; - 8th April 2007 at 03:45. Reason: needed to add more info

  8. #8
    Join Date
    Sep 2005
    Location
    Campbell, CA
    Posts
    1,107


    Did you find this post helpful? Yes | No

    Default

    No, DEFINE OSC 8 tells PBP that the chip is running 8Mhz. It uses this
    value to set the length of all its software timing loops. This does NOT
    cause the chip to run at 8Mhz.

    You need to define the oscillator type in the configuration fuses. Look at the
    oscillator configurations in the datasheet for your processor, and then do
    a search on "configuration bits" in this forum.
    Charles Linquist

  9. #9
    Join Date
    Aug 2006
    Location
    Look, behind you.
    Posts
    2,818


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by ttease View Post
    Verified, using MPASM 5.1.

    If I want to config the PIC to run at 8mHz, I thought it was simply this:

    DEFINE OSC 8

    Is this incorrect?

    t
    Look this over.

    http://www.picbasic.co.uk/forum/showthread.php?t=543
    If you do not believe in MAGIC, Consider how currency has value simply by printing it, and is then traded for real assets.
    .
    Gold is the money of kings, silver is the money of gentlemen, barter is the money of peasants - but debt is the money of slaves
    .
    There simply is no "Happy Spam" If you do it you will disappear from this forum.

  10. #10
    Join Date
    Mar 2007
    Posts
    17


    Did you find this post helpful? Yes | No

    Default More info

    Thanks for the links and info.

    Okay, I read the threads suggested and I'm more confused than before but I believe I have the bits set. I checked by importing the *.asm file into MPLab ver 7.52 and looked at the 'configuration bit' and they are set as I wanted.

    I got this working by modifing the 18f4431.inc file to this:

    ; __CONFIG _CONFIG1H, _OSC_XT_1H
    ; __CONFIG _CONFIG2H, _WDTEN_ON_2H & _WDPS_128_2H
    __CONFIG _CONFIG1H, _OSC_IRCIO_1H
    __CONFIG _CONFIG2H, _WDTEN_OFF_2H & _WDPS_128_2H
    __CONFIG _CONFIG4L, _LVP_OFF_4L

    My question now is what is the current way of setting these bits. These threads as ~ a year old and I'm not sure which way to go with the '__config' being replaced by 'CONFIG' so I comment all the '__CONFIG' lines out and added:

    CONFIG OSC=IRC,WDTEN=ON,WDPS=128,LVP=OFF

    Is there a better way to do this? Can I add it to the *.bas file?

  11. #11
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by ttease View Post
    Thanks for the links and info.

    Okay, I read the threads suggested and I'm more confused than before but I believe I have the bits set. I checked by importing the *.asm file into MPLab ver 7.52 and looked at the 'configuration bit' and they are set as I wanted.

    I got this working by modifing the 18f4431.inc file to this:

    ; __CONFIG _CONFIG1H, _OSC_XT_1H
    ; __CONFIG _CONFIG2H, _WDTEN_ON_2H & _WDPS_128_2H
    __CONFIG _CONFIG1H, _OSC_IRCIO_1H
    __CONFIG _CONFIG2H, _WDTEN_OFF_2H & _WDPS_128_2H
    __CONFIG _CONFIG4L, _LVP_OFF_4L

    My question now is what is the current way of setting these bits. These threads as ~ a year old and I'm not sure which way to go with the '__config' being replaced by 'CONFIG' so I comment all the '__CONFIG' lines out and added:

    CONFIG OSC=IRC,WDTEN=ON,WDPS=128,LVP=OFF

    Is there a better way to do this? Can I add it to the *.bas file?
    You can make those changes 'permanent' by changing the correct .inc file for whatever specific processor you're using. But you have to watch it. If you want something different for that same processor type on a different project, you'll have to change the .inc file again.
    Maybe you could "include" a seperate file that has all of those settings in it...i.e. include "normal.bas" or include "special.bas" and each of those .bas file would have all of you config settings in it, without all of the extra lines to worry about. Then they'd be 'permanent'.

Similar Threads

  1. High Resolution Timer & Speed Calculator
    By WOZZY-2010 in forum Code Examples
    Replies: 4
    Last Post: - 7th February 2010, 16:45
  2. Hello, long time no post (ADC sample rate)
    By Jhong2 in forum General
    Replies: 0
    Last Post: - 14th April 2009, 04:13
  3. Pic16f84 and RC5 kode
    By terminator in forum Bluetooth
    Replies: 5
    Last Post: - 18th June 2007, 21:40
  4. Replies: 2
    Last Post: - 27th March 2007, 12:48
  5. Using RTC to generate long time delays
    By schlaray in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 3rd January 2007, 00:31

Members who have read this thread : 0

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts