Searching \ for 'Continious delay' in subject line. ()
Make payments with PayPal - it's fast, free and secure! Help us get a faster server
FAQ page: techref.massmind.org/techref/timers.htm?key=delay
Search entire site for: 'Continious delay'.

Truncated match.
PICList Thread
'Continious delay'
1998\03\05@230122 by Gennady Palitsky

flavicon
face
I believe this should be simple, but don't have an idea as of right now.
To generate delay I am using standard procedure:

LOOP
   decfsz    COUNTER,1
   goto        LOOP
------------------
As far as I understand, both DECFSZ and GOTO are 2 cycle instructions, so 1
point change in COUNTER value gives me 4 cycles change in delay time (am I
wrong?).
Is there any way to generate delay which will give me 1:1 ratio (1 point
change in COUNTER value : 1 cycle change in delay time). Or do I want too
much?

Gennady Palitsky
Jefferson Audio Video Systems
spam_OUTgennadypTakeThisOuTspammainlink.net

1998\03\06@050210 by Andrew Warren

face
flavicon
face
Gennady Palitsky <.....PICLISTKILLspamspam@spam@MITVMA.MIT.EDU> wrote:

> I believe this should be simple, but don't have an idea as of right
> now. To generate delay I am using standard procedure:
>
> LOOP
>     decfsz    COUNTER,1
>     goto        LOOP
> ------------------
> As far as I understand, both DECFSZ and GOTO are 2 cycle
> instructions, so 1 point change in COUNTER value gives me 4 cycles
> change in delay time (am I wrong?).

   Gennady:

   Yes, you're wrong... The DECFSZ only takes two cycles on the
   FINAL iteration of the loop (when the GOTO is skipped); every
   other time through the loop, it takes just one cycle.

   The GOTO is a two-cycle instruction, so the total delay is X*3-1,
   where X is the value loaded into the counter before the loop.

> Is there any way to generate delay which will give me 1:1 ratio (1
> point change in COUNTER value : 1 cycle change in delay time). Or
> do I want too much?

   Try this; it generates delays with a resolution of one cycle,
   although it's limited to the range [20-271].

       MOVLW   X
       CALL    DELAY

       ....

   ; This routine delays X cycles.  Enter with X (in the range
   ; [20-271]) in the W register.
   ;
   ; Note that the delay is inclusive of the "MOVLW X", "CALL
   ; DELAY", and "RETURN" overhead, so a sequence like:
   ;
   ;     MOVLW   100
   ;     CALL    DELAY
   ;     MOVLW   200
   ;     CALL    DELAY
   ;
   ; will delay EXACTLY 300 cycles.

   DELAY:

       MOVWF   COUNTER

       BTFSC   COUNTER, 0
       GOTO    $+1

       BTFSS   COUNTER, 1
       GOTO    SKIP
       NOP
       GOTO    $+1

   SKIP:

       RRF     COUNTER
       RRF     COUNTER

       MOVLW   4
       SUBWF   COUNTER

       BCF     COUNTER,6
       BCF     COUNTER,7

   LOOP:

       NOP
       DECFSZ  COUNTER
       GOTO    LOOP

       RETURN

   As is always the case with code that I write online, this code
   has neither been tested nor even assembled.

   -Andy

=== Andrew Warren - fastfwdspamKILLspamix.netcom.com
=== Fast Forward Engineering - Vista, California
=== http://www.geocities.com/SiliconValley/2499

1998\03\06@072908 by Caisson

flavicon
face
> Van: Gennady Palitsky <.....gennadypKILLspamspam.....MAINLINK.NET>
> Aan: EraseMEPICLISTspam_OUTspamTakeThisOuTMITVMA.MIT.EDU
> Onderwerp: Continious delay
> Datum: vrijdag 6 maart 1998 9:16
>
> I believe this should be simple, but don't have an idea as of right now.
> To generate delay I am using standard procedure:
>
> LOOP
>     decfsz    COUNTER,1
>     goto        LOOP
> ------------------
> As far as I understand, both DECFSZ and GOTO are 2 cycle instructions, so
1
> point change in COUNTER value gives me 4 cycles change in delay time (am
I
> wrong?).

I do not like to be the one to tell you, but yes, you're wrong. So there
:-)

A conditional command is a 1 -OR- 2 cycle command, depending on the
outcome of the compare.

Explanation:
If you don't skip the next command you can continue with the _pre-fetched_
next
command.
If you skip the next command (or perform a 'goto') , you'll have to ignore
the
pre-fetched next command (and lose a cycle), and get a new command.

Your delay-routine has a delay of 3 * (COUNT-1) +2 cycles
- When COUNT <> 1 -> Decfsz := 1 cycle, Goto := 2 cycles
- When COUNT == 1 -> Decfsz := 2 cycles, goto := <skipped>

> Is there any way to generate delay which will give me 1:1 ratio (1 point
> change in COUNTER value : 1 cycle change in delay time). Or do I want too
> much?

You could try to use the Timer-module, if your PIC has got one.

> Gennady Palitsky
> Jefferson Audio Video Systems
> gennadypspamspam_OUTmainlink.net

Greetz,
 Rudy Wieser

More... (looser matching)
- Last day of these posts
- In 1998 , 1999 only
- Today
- New search...