Odd behavior if too many instructions


Closed Thread
Results 1 to 14 of 14

Hybrid View

  1. #1
    Join Date
    Feb 2010
    Posts
    11

    Default Odd behavior if too many instructions

    I'm using a 16f877a on a Lab X-2 board, at 20mhz. I'm using microcode studio plus w/PBP and MicroCode Loader bootloader.

    My program has an assembly interrupt routine, which to my knowledge is correct. I have a simple:

    main:

    LED = 1
    pause 50
    LED = 0

    goto Main

    Other_Routines:
    ...
    End

    Although right now my program DOES NOT use "Other Routines"... they somehow affect my program. If I move my encoder, which triggers the assembly interrupt, and I have not commented out "Other Routines", there is considerable lag in the time the LED blinks on off. If I delete a large portion of my unused routine (other routine) then the LED blinks on/off normally dispite the huge number of interrupts, which don't take a long time to process.

    I am totally lost. Without the "other routines" my code only takes ~800 words. With it, it's over 1100. I'm wondering if I'm going into a different page, but then I"m not sure because my code is still less than 2k words... if I did go into a new page... what are the consequences of that?

    Matt

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


    Did you find this post helpful? Yes | No

    Wink

    Hi, Matt

    Without your "Faulty" code ... no luck to tell you something usable ...

    could be as simple as an Interrupt flag you've forgotten to reset ...

    COULD be ...

    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
    Feb 2010
    Posts
    11


    Did you find this post helpful? Yes | No

    Default

    Here is my code:

    http://pastebin.com/f456e5db

    Sorry it's a bit of a mess. If I comment the "IF" on Line 343, with the corresponding ENDIF, the code runs much more consistently. Also, "Encoder_Counting" at 395 disabled interrupts to do some processing, but only for a few lines while it copies a buffer. If I disable interrupts for the entire routine, one of my problems goes away. The problem was that "Current_Position" got changed randomly. I guessed that my interrupt was screwing with it, so I disabled interrupts for that entire routine. Theoretically, my interrupt shouldn't interfere with that at all. None of the variables there are used by the interrupt. When I copy from the variables which are used during the interrupt, I disable global interrupts. ::Confused::

    About assembly interrupts, when I use them I only restore the W register. Do I need to do anything with wsave1, wsave2, or wsave3? I know I have to declare them, but I"m not sure where they get used.

    Thanks,
    MAtt

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


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by dksoba
    I'm using microcode studio plus w/PBP and MicroCode Loader bootloader.
    Try adding ...
    Code:
    DEFINE LOADER_USED 1 ' Bootloader Used
    DT

  5. #5
    Join Date
    Feb 2010
    Posts
    11


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Darrel Taylor View Post
    Try adding ...
    Code:
    DEFINE LOADER_USED 1 ' Bootloader Used
    That is defined in generic_include.inc. I moved it to my main pbp file and removed that include, and it still does the same thing.

    Does this have something to do with stacksize? If you overflow the stack... what happens?

    Matt

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


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by dksoba View Post
    Does this have something to do with stacksize? If you overflow the stack... what happens?
    It has nothing to do with the stack.
    It just makes sure nothing is in the first 4 words.
    Those locations are needed for the Bootloader.

    And when you overflow the stack on 16F's ... Nothing happens.
    It's when you return, that you may end up in the wrong place.

    What else is in your Includes?
    Can you post them too?
    <br>
    DT

Similar Threads

  1. PBP Using too many instructions
    By The Master in forum mel PIC BASIC Pro
    Replies: 14
    Last Post: - 21st December 2009, 23:24
  2. Difference between modes in serial instructions
    By amindzo in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 16th September 2008, 15:40
  3. Is Number Odd?
    By T.Jackson in forum Off Topic
    Replies: 29
    Last Post: - 11th June 2008, 17:53
  4. List of instructions used in PBP ?
    By AndrewC in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 2nd November 2007, 11:22
  5. Need more speed in Lookdown and Branchl instructions
    By Pedro Santos in forum mel PIC BASIC Pro
    Replies: 0
    Last Post: - 18th August 2006, 23:04

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