Delay without using pause


Closed Thread
Results 1 to 40 of 43

Hybrid View

  1. #1
    Join Date
    Oct 2014
    Location
    Lagos Nigeria
    Posts
    10


    Did you find this post helpful? Yes | No

    Default Re: Delay without using pause

    Thank so much Henrick,

    i am so glad that someone understood what i was trying to say. Elated to hear that it is doable even in the ms range.

    But to answer some of your questions:

    1) By system registers i was thinking that pbp must setup some timers for counting during pause. And this might affect my timers usage.

    2) how i am doing my interrupts. I use DEFINE INTHAND _MYISR1

    Then after saving contexts in asm i do an endasm and gosub a pbp routine. I don't know how to upload a code yet. I would have shown you.

    But at any rate, the results are usually erratic and it seems as if the code is making jumps to the wrong places. On certain ocassions i found out that if i use a timer interupt to delay something rather than pause, the system will work better.

    3) Now since pause is blocking, "just like all pbp commands" (never thought if this) if i can get a way to rig up a macro that i can use such as

    @ myPAUSE msec,SUBNAME

    where msec is the no of ms to delay and SUBNAME is used to keep track of the specific registers to use (i.e the sub that is calling for a delay).

    My problem is: can i call a pbp routine inside asm macro.

    I like to use pbp if statements to in a state-machine-like manner, makes programming more structured. If i can have another type of PAUSE that will simply load a reg and move... i think this will make code more efficient

    Thanks so much.

  2. #2
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,627


    Did you find this post helpful? Yes | No

    Default Re: Delay without using pause

    Hi,
    1) By system registers i was thinking that pbp must setup some timers for counting during pause. And this might affect my timers usage.
    No, not at all. The PAUSE and PAUSEUS commands does not use any hardware peripherals (ie timers) on the PIC, it's done in software which is why it's blocking. Basically it sits in a loop, counting cycles.

    2) how i am doing my interrupts. I use DEFINE INTHAND _MYISR1

    Then after saving contexts in asm i do an endasm and gosub a pbp routine. I don't know how to upload a code yet. I would have shown you.

    But at any rate, the results are usually erratic and it seems as if the code is making jumps to the wrong places. On certain ocassions i found out that if i use a timer interupt to delay something rather than pause, the system will work better.
    OK, so there's your problem I think. If you use ASM for your interrupt service routines you can (generally) not use PBP code within the ISR (using a GOSUB does not matter). Why? Because PBP uses its internal system variable for its various commands, if your main program is in the middle of comlex math operation it stores intermediate results in its internal variables and along comes an interrupt. If you then place PBP commands in the ISR chanses are that code wants to use the same internal system variables which will the corrupt the complex math operation that the main program was in the middle of calculating.

    If you want to use PBP within your interrupt servie routine you need to either:

    A) Use ON INTERRUPT - with its drawbacks.
    B) Write the code for the handler, compile and assemble it. Examine the .lst file and determine which of the system variables are being used and then add code to save and restore those registers on ISR entry/exit.
    C) Use Darrel Taylors Instant Interrupt routines. What it does is save and restore ALL PBP system variables on entry/exit. It comes at a cost of interrupt latency (it takes time to save all the registers).

    I've used all three of the above aproaches. By far, option C is "the best". I very very rarely use A. B I've used for stuff where the ISR is simple and I've really needed the speed. Just remember that with option B you need to be very careful, any change to ISR and you need to re-examin the generated code to see if any new PBP system variables are beinng used.

    3) Now since pause is blocking, "just like all pbp commands" (never thought if this) if i can get a way to rig up a macro that i can use such as

    @ myPAUSE msec,SUBNAME

    where msec is the no of ms to delay and SUBNAME is used to keep track of the specific registers to use (i.e the sub that is calling for a delay).

    My problem is: can i call a pbp routine inside asm macro.
    I don't quite follow you with the macro thing (I truly suck at the ASM stuff) but if you mean calling a PBP subroutine from within an ASM interrupt service routine then generally NO, absolutely not.

    /Henrik.

Similar Threads

  1. Replies: 6
    Last Post: - 28th October 2014, 07:08
  2. Do I need a pause?
    By tazntex in forum Serial
    Replies: 21
    Last Post: - 29th August 2008, 05:32
  3. 1 us delay
    By Pedro in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 18th February 2006, 18:28
  4. Pause
    By blue in forum General
    Replies: 7
    Last Post: - 29th December 2005, 15:24
  5. pause 0.5
    By detail in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 27th June 2005, 12:32

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