Searching \ for '[PIC]: delay' in subject line. ()
Make payments with PayPal - it's fast, free and secure! Help us get a faster server
FAQ page: www.piclist.com/techref/microchip/time.htm?key=delay
Search entire site for: 'delay'.

Exact match. Not showing close matches.
PICList Thread
'[PIC]: delay'
2001\02\03@165947 by Tweedy Bird

picon face
Hi everyone,

I am trying to generate a delay for the 20 MHz PIC16F877 that I
am using to interface it to the LCD.  I think I don't understand
how to generate the delay because I know that my hardware is
working perfectly.  Can some one please tell me how to calculate
the delay in seconds for the following code.
Thank you
Sarah

LOOPD   equ   2Ah
.
.
.

delay   movlw   .90
       movwf   LOOPD
repeat  nop
       decfsz  LOOPD
       goto    repeat
       return




_________________________________________________________________________
Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com.

--
http://www.piclist.com hint: The PICList is archived three different
ways.  See http://www.piclist.com/#archives for details.


2001\02\03@174520 by rich+piclist

flavicon
face
20 Mhz is 200nS per instruction cycle. You are making 90 passes through
four cycle loop.

200nS*90*4=72uS, 72.8 with overhead.

On Sat, 3 Feb 2001, Tweedy Bird wrote:

{Quote hidden}

--
http://www.piclist.com hint: The PICList is archived three different
ways.  See http://www.piclist.com/#archives for details.


2001\02\03@215923 by Drew Vassallo

picon face
>20 Mhz is 200nS per instruction cycle. You are making 90 passes through
>four cycle loop.
>
>200nS*90*4=72uS, 72.8 with overhead.

Actually, the code below would be 72.6us with overhead (the last time
through the loop, the 'goto' is only a one-cycle nop).

> > delay   movlw   .90
> >         movwf   LOOPD
> > repeat  nop
> >         decfsz  LOOPD
> >         goto    repeat
> >         return

--Andrew

_________________________________________________________________
Get your FREE download of MSN Explorer at http://explorer.msn.com

--
http://www.piclist.com hint: The PICList is archived three different
ways.  See http://www.piclist.com/#archives for details.


2001\02\04@020348 by BENEDICIC SAMO

flavicon
face
Hi!

For me, the easiest way to calculate the delay  is to write the code into a
project I call TEST.PJT
(all processor definitions, include files and the command line are already
there ). Then I step with F6 to the beginning of the delay loop, reset the
stopwatch and run the code through the loop with RUN TO HERE command. Then I
simply change start value of say LOOPD and try again until I'm happy with my
delay. Works fine when you don't need to be too exact ( few instruction
cycles up or down ).
How long must your delay be? Regards, Samo

{Original Message removed}

2001\02\04@120246 by Olin Lathrop
face picon face
> I am trying to generate a delay for the 20 MHz PIC16F877 that I
> am using to interface it to the LCD.  I think I don't understand
> how to generate the delay because I know that my hardware is
> working perfectly.  Can some one please tell me how to calculate
> the delay in seconds for the following code.
> Thank you
> Sarah
>
> LOOPD   equ   2Ah
> .
> .
> .
>
> delay   movlw   .90
>         movwf   LOOPD
> repeat  nop
>         decfsz  LOOPD
>         goto    repeat
>         return

I personally don't like busy-waits much.  The timing can't be relied on when
there are interrupts, and the processor is completely out to lunch during
the wait.

Especially when the wait is more than a few milliseconds, I prefer to set up
a periodic interrupt.  1mS is often a convenient interrupt period.  The
interrupt routine decrements a counter if it is not already zero.  The
foreground code sets the counter then checks for it to become zero.
Meanwhile, it can be doing other tasks, as long as it gets back to checking
the wait counter fast enough.

Note that you can support more than one simultaneous wait counter this way,
and they can each be clocked at a separate multiple of the interrupt period.
I've had projects that simultaneously used 1mS, 10mS, and 100mS wait
counters, all derived from the basic 1mS interrupt.


*****************************************************************
Olin Lathrop, embedded systems consultant in Devens Massachusetts
(978) 772-3129, .....olinKILLspamspam.....embedinc.com, http://www.embedinc.com

--
http://www.piclist.com#nomail Going offline? Don't AutoReply us!
email EraseMElistservspam_OUTspamTakeThisOuTmitvma.mit.edu with SET PICList DIGEST in the body


2001\02\04@135510 by Peter L. Peres

picon face
>delay   movlw   .90            ; 1T
>        movwf   LOOPD          ; 1T
>repeat  nop                    ; 1T  (1T while looping)
>        decfsz  LOOPD          ; 2T  (1T while looping)
>        goto    repeat         ; 0T  (2T while looping)
>        return                 ; 2T

The timing of your code is:

T = 7 + 4 * (90 - 1) = 363 T cycles not counting the 2T cycles required by
the call. This is 363 usec with a 4MHz crystal.

Peter

--
http://www.piclist.com#nomail Going offline? Don't AutoReply us!
email listservspamspam_OUTmitvma.mit.edu with SET PICList DIGEST in the body


2001\02\04@222405 by rich+piclist

flavicon
face
On Sat, 3 Feb 2001, Drew Vassallo wrote:

> Date: Sat, 3 Feb 2001 21:59:23 -0500
> From: Drew Vassallo <@spam@snurpleKILLspamspamHOTMAIL.COM>
> Reply-To: pic microcontroller discussion list <KILLspamPICLISTKILLspamspamMITVMA.MIT.EDU>
> To: RemoveMEPICLISTTakeThisOuTspamMITVMA.MIT.EDU
> Subject: Re: [PIC]: delay
>
> >20 Mhz is 200nS per instruction cycle. You are making 90 passes through
> >four cycle loop.
> >
> >200nS*90*4=72uS, 72.8 with overhead.
>
> Actually, the code below would be 72.6us with overhead (the last time
> through the loop, the 'goto' is only a one-cycle nop).
Thanks, I was including the call but forgetting the skip... but what's a
couple hundred light-feet?

{Quote hidden}

--
http://www.piclist.com#nomail Going offline? Don't AutoReply us!
email spamBeGonelistservspamBeGonespammitvma.mit.edu with SET PICList DIGEST in the body


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