Searching \ for '[PIC]: Long Accurate Timing loops' 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/devices.htm?key=pic
Search entire site for: 'Long Accurate Timing loops'.

Exact match. Not showing close matches.
PICList Thread
'[PIC]: Long Accurate Timing loops'
2003\11\16@121714 by Oliver Broad

flavicon
face
I've been away from PICs for some time now

I've recently offered to write a program that involves frequency counting
and so I got to thinking about timing loops. I searched PICLIST and it
seemed as if there were long time delays, accurate time delays, but no long
and accurate timing delays. I recall some discussion on this and a few
one-byte counters that were cycle accurate.

Would anyone like to comment on this code fragment for a two byte
cycle-accurate delay loop:

movlw high delay
 movwf delayhi
 movlw low delay
 movwf delaylo
d1  incf delayhi,f
 movlw D'5'
loop subwf delaylo,f
 skpc
 decfsz delayhi,f
 goto loop  ;5 cycle loop
 comf delaylo,w
 addwf PCL,f
 nop
 nop
 nop
 nop
d2

The delay between d1 and d2 is the value of "delay" plus nine cycles and I
have been unable to find any trick values that trip it up so far. The loop
finishes with a negative number in "delaylo" and COMF converts it to a
number between 0 and 4 used to add up to four "noops"

I guess that on a 14 bit pic delaylo could be stored in the W register?

Oliver

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

2003\11\16@124031 by Oliver Broad

flavicon
face
I'd like to add to my previous post that I'm getting an odd sense of
deja-vu. I suspect I've just re-created something someone else devised
originally.

Anyone recall?

{Original Message removed}

2003\11\16@131605 by

picon face
Why not use one of the timers ?
Jan-Erik.

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

2003\11\16@135232 by Oliver Broad

flavicon
face
I'll be using the timer to count pulses!

The loop is to set the "window", though actually I just got curious about
delay generation.

Oliver
{Original Message removed}

2003\11\17@035059 by Ian McLean
flavicon
face
Why not get the "Zero-Error One second timer" from Roman Black.  Written in
MPASM and available at http://www.romanblack.com/one_sec.htm

This can modified for any time delay.  Great bit of code.

BTW, whatever happened to Roman ?

Rgs
Ian.

> {Original Message removed}

2003\11\17@035647 by

picon face
Oliver Broad wrote:
>
> From: "Jan-Erik Soderholm XA (TN/PAC)"
>
> > Why not use one of the timers ?
> > Jan-Erik.
>
> I'll be using the timer to count pulses!
>

*The* timer ?

Most PIC has a couple of them, maybe use one timer
for the "window" and another for the counting...

Or is this a 16F84 design ? I think that one had
just one timer (?)...

Jan-Erik.

--
http://www.piclist.com hint: To leave the PICList
piclist-unsubscribe-requestspamKILLspammitvma.mit.edu

2003\11\17@164114 by James Cameron

flavicon
face
On Mon, Nov 17, 2003 at 09:55:37AM +0100, Jan-Erik Soderholm XA (TN/PAC) wrote:
> Or is this a 16F84 design ? I think that one had
> just one timer (?)...

No, two.  TMR0 and the watchdog.  The latter includes a potentially
useful temperature dependency.

--
James Cameron    .....quozlKILLspamspam.....us.netrek.org     http://quozl.netrek.org/

--
http://www.piclist.com hint: To leave the PICList
EraseMEpiclist-unsubscribe-requestspam_OUTspamTakeThisOuTmitvma.mit.edu

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