pauseus behaviour, 18f2455


Closed Thread
Results 1 to 5 of 5
  1. #1
    mark_wotton's Avatar
    mark_wotton Guest

    Default pauseus behaviour, 18f2455

    Hi,

    I'm having a strange problem with inconsistent timing using pauseus. I wrote the following test program:

    Code:
    define OSC 08
    osccon = %01110010
    
    for i = 1 to 10
     high statusled
     for j = 1 to X
       pauseus Y
     next j
     low statusled
     for j = 1 to X
       pauseus Y
     next j
    next i
    and tested it, substituting for the following X,Y pairs

    1000,5000
    2500,2000
    5000,1000
    10000,500
    25000,200

    For Y=2000 and above, I get exactly what I expect: an LED flashing
    once a second for 10 seconds. For lower parameters to pauseus, however
    i get the following results:

    1000,5000 -> 10s
    2500,2000 -> 10s
    5000,1000 -> 5s
    10000,500 -> 2.6s
    25000,200 -> 1.0s

    pauseus is meant to work down to 12 us for my 8mhz clock, according to
    the PicBasic manual: can anyone suggest what might be wrong, or what
    tests I might run to narrow it down?

    Mark
    Last edited by mark_wotton; - 7th September 2006 at 11:46. Reason: formatting fix

  2. #2
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    i'm not sure but what about
    DEFINE OSC 8

    Define's must be written perfectly OR they will never be considered... but it's a guess.

    For few uSec, i usually use assembler. @4MHz each @ nop is 1 uSec, and, of course, each @ nop @ 8MHz is 0.5 uSec.
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  3. #3
    mark_wotton's Avatar
    mark_wotton Guest


    Did you find this post helpful? Yes | No

    Default Mea culpa, mea culpa, mea maxima culpa

    Thanks, I'll remember that. But the root cause of the problem was forgetting that you can't fit "10000" into a byte. Oops...

  4. #4
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Talking

    LMAO! ok...
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  5. #5
    Join Date
    Jan 2006
    Location
    Istanbul
    Posts
    1,185


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by mark_wotton
    Thanks, I'll remember that. But the root cause of the problem was forgetting that you can't fit "10000" into a byte. Oops...

    If you have to use Byte variables, you can actually use small numbers and with PauseUS command you may do the following.

    PausUS Y*100

    say Y= 50 then PauseUS Y*50 will give you PauseUs 5000.

    and others the same way...


    ---------------
    "If the Earth were a single state, Istanbul would be its capital." Napoleon Bonaparte

Similar Threads

  1. PICs can do more if use others than delays instructions
    By hardcore in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 24th February 2010, 19:52
  2. Sony LanC Program
    By l_gaminde in forum Code Examples
    Replies: 2
    Last Post: - 25th September 2009, 18:51
  3. RC5 decode on a 10F + Question
    By ultiblade in forum mel PIC BASIC Pro
    Replies: 8
    Last Post: - 11th September 2008, 08:20
  4. LANC code 12F675
    By MikeDD in forum General
    Replies: 4
    Last Post: - 9th May 2008, 05:44
  5. reducing shiftout clock freq and PS2/PC interfacing ....
    By wireless magic in forum mel PIC BASIC Pro
    Replies: 18
    Last Post: - 26th February 2008, 20:15

Members who have read this thread : 1

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