Issue with Array causing PauseUS to have 16uS overhead


Closed Thread
Results 1 to 6 of 6
  1. #1
    Join Date
    Feb 2003
    Location
    Sydney, Australia
    Posts
    126

    Default Issue with Array causing PauseUS to have 16uS overhead

    I have the following at the top of my code to initialise a 65 byte array to 0:
    <code>
    for x = 0 to 64
    ch[x] = 0
    next
    </code>

    This initialises my array to all 0 values. Problem is that any PauseUS I use after this have an overhead of 16uS, so a PauseUs 8 becomes 24uS.

    If I comment out the For...Next loop then the time penalty goes, although I get crap in the array. I assume I must be crossing a code boundary or some such thing and this causes the extra overhead when bank switching occurs.

    Any one have any idea ?? I don't really need my PauseUS to be accurate for this, but I am interested how a simple change could cause so much of a latency in another statement.

    Any tips on optimisation ??

    Using PBP2.47

    Thanks,
    Bill.

  2. #2
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,614


    Did you find this post helpful? Yes | No

    Lightbulb

    Hi, Bill

    Just a stupid basic line :

    GOSUB Manual_pauseus_minimum_delay_section '...

    Bet your osc is default 4Mhz ...

    The only tip :

    Insert

    @ NOP
    .
    .
    .
    .
    @ NOP

    Alain
    ************************************************** ***********************
    Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
    ************************************************** ***********************
    IF there is the word "Problem" in your question ...
    certainly the answer is " RTFM " or " RTFDataSheet " !!!
    *****************************************

  3. #3
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default

    The PAUSEUS statement has a minimum time it can delay.
    It has to calculate what to do each use at Run-Time.

    @ &nbsp;4Mhz, the delay is 24us

    A "1us minimum" delay routine can be found here ...
    http://www.picbasic.co.uk/forum/showthread.php?p=22098

    Another possibility is corruption of the Pause command from using a Bootloader without ...
    DEFINE LOADER_USED 1
    ( but, nobody ever admits to that one. )
    <br>
    DT

  4. #4
    Join Date
    Feb 2003
    Location
    Sydney, Australia
    Posts
    126


    Did you find this post helpful? Yes | No

    Default

    The PIC is running at 20MHz. I have Define OSC 20 at the top of the code.
    I am not using Interrupts. Its a simple State Machine loop that runs correctly without the For-Next loop that clears the array.

    Without the For-Next loop the PauseUS has the correct time, but with it the PauseUS time is way off.

    I tried using NOPs, but was still getting a long delay. I think it must an interaction between the for-next loop that clears the array and the HSEROUT.

    I borrowed a DSO from work so I can do a bit of in depth investigation into what is happening and why.

    I will post the code later when I have it to hand.

    bill.

  5. #5


    Did you find this post helpful? Yes | No

    Default CLEAR should set your array to all zeros

    I think CLEAR will zero all your variables without you needing the For..Next lines you now have.

    HTH
    Brian

  6. #6
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,614


    Did you find this post helpful? Yes | No

    Post

    Hi, Bill

    1) why not try to place your delay comp. just BEFORE the loop ??? ( could help for debugging too ... )

    2) you can assign your variables banking ... see $ 7.3



    Now, 16µS @ 20 MHz is ~ 60-80 assembler lines ... that make a lot of bank switchings ... if it is bank switching.

    What's your processor ???

    Alain
    ************************************************** ***********************
    Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
    ************************************************** ***********************
    IF there is the word "Problem" in your question ...
    certainly the answer is " RTFM " or " RTFDataSheet " !!!
    *****************************************

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