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

Exact match. Not showing close matches.
PICList Thread
'[PIC]: 500 Us pause on 12c508'
2000\08\12@131108 by Greg Wood

picon face
There lets see if I get it right this time.  Now, maybe someone else could
tell me how change the length of the pause in the code below, that a member
of the list was nice enough to provide.  Last time I apparently tagged it
wrong.  Oh, well.
could someone explain how to lengthen the pause created by this code? Keep
in mind I don't know any assembler.  I have the pause added to the code I
was trying to modify, and it works, but is a little to short.  If it just
involves changing a number, explain the math to get the desired pause, say
600 Us.  If it involves something totally different, maybe just send the
code for a 600 Us, and 700Us pause.  Here is the code.

call    abit
;-----------------------
abit:                   ;500 us delay loop for 4 MHz crystal
        movlw   .124
        movwf   t1
        clrwdt
        DECFSZ  t1,f
        GOTO    $-2
        return
;--------------------------


thanks for the help.


{Quote hidden}

________________________________________________________________________
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.

2000\08\12@133014 by Fredrik Selin

flavicon
face
Here you go:

us = (t1 * 4) - 4

ex.

600 us = (t1 * 4) - 4
600 + 4 = t1 * 4
604 / 4 = t1

Regards, Fredrik
:-)

{Original Message removed}

2000\08\12@190712 by Heinz Czychun

flavicon
face
At 11:09 AM 8/12/2000, Greg Wood wrote:
>There lets see if I get it right this time.  Now, maybe someone else could
>tell me how change the length of the pause in the code below, that a member
>of the list was nice enough to provide.  Last time I apparently tagged it
>wrong.  Oh, well.
>could someone explain how to lengthen the pause created by this code? Keep
>in mind I don't know any assembler.  I have the pause added to the code I
>was trying to modify, and it works, but is a little to short.  If it just
>involves changing a number, explain the math to get the desired pause, say
>600 Us.  If it involves something totally different, maybe just send the
>code for a 600 Us, and 700Us pause.  Here is the code.

Hi Greg,

       This is how I'd analyze the code;


call    abit            ;                                       2
instruction cycles
;
;--------------------------     each instruction cycle takes 4 clock pulses
                       ;       therefore each cycle is 1 uS
                                               ;
abit:                   ;       500 uS delay loop for 4 MHz crystal
;
        movlw   .124   ;       load N = 124 decimal            1
instruction cycle
        movwf   t1     ;       into t1 register                1
        clrwdt         ;       clear wdt *                     1 *  N

        DECFSZ  t1,f   ;       decrement t1 and check if = 0   1 * (N-1)
+ 2 for last count
        GOTO    $-2    ;       if not go back 2 locations      2 * (N-1)
since not executed on
                       ;
last count
                       ;       (to the clrwdt instruction)
        return         ;       if t1 = 0 return from sub       2
;--------------------------                                  ---------
                                               total time =  3 * ( N - 1)
+ N + 8
                                                             4 * N + 5
                                                             (124 * 4) + 5
                                                             501 uS

* Note: This instruction could be a NOP but using clrwdt here, has the
added benefit of
       reseting the Watchdog Timer (if enabled) each time through the loop.

600 uS
( 600 - 5 )/4 = 148.75
then the number to load is 149, and the timing will be long by 1uS

700 uS
( 700 - 5 )/4 = 173.75
then the number to load is 174, and the timing will be long by 1uS

Further the maximum delay is ( obtained when t1 = 0, then N = 256 ) = 1.029 mS.


Heinz

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

2000\08\12@214343 by Greg Wood

picon face
thanks for the help, but I still can't get it to work.  I tried substituing
in .150 for .124, and it was like I hadn't even added the delay.  What
gives? I am very confused.


{Quote hidden}

________________________________________________________________________
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.

2000\08\12@230449 by Heinz Czychun

flavicon
face
Hi Greg,

       The delay subroutine should work. How are you measuring the delay,
and what does the code look like that's calling the delay?

Heinz

At 7:42 PM 8/12/2000, Greg Wood wrote:
>thanks for the help, but I still can't get it to work.  I tried substituing
>in .150 for .124, and it was like I hadn't even added the delay.  What
>gives? I am very confused.
>
>

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

2000\08\13@120529 by Olin Lathrop

flavicon
face
> could someone explain how to lengthen the pause created by this code? Keep
> in mind I don't know any assembler.
>
> ...
>
>          movlw   .124
>          movwf   t1
>          clrwdt
>          DECFSZ  t1,f
>          GOTO    $-2
>          return

The time is proportional to the MOVLW value, plus a small constant.  The
actual time depends on the clock speed.  Adjust it relative to what you are
getting now, although 256 is the maximum value you can change the 124 to.

However, it's not a good idea to go messing with something you don't
understand.  I recommend you either learn the assembler, do it in a language
you do understand, or get someone who does understand it to do it.


*****************************************************************
Olin Lathrop, embedded systems consultant in Devens Massachusetts
(978) 772-3129, @spam@olinKILLspamspamcognivis.com, http://www.cognivis.com

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

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