Searching \ for '[PIC] crystal is 6.167MHz. how to do 1us in 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: 'crystal is 6.167MHz. how to do 1us in delay.'.

Exact match. Not showing close matches.
PICList Thread
'[PIC] crystal is 6.167MHz. how to do 1us in delay.'
2009\01\28@101544 by microsoftwarecontrol

flavicon
face
part 1 108 bytes content-type:text/plain; (decoded quoted-printable)

how to deal with 6.167MHz ?

Thought days, no goog solution!

part 2 35 bytes content-type:text/plain; charset="us-ascii"
(decoded 7bit)

2009\01\28@103022 by olin piclist

face picon face
part 1 601 bytes content-type:text/plain; (decoded 7bit)

microsoftwarecontrol wrote:
> how to deal with 6.167MHz ?

Feed it into the oscillator input of a PIC.

Stick a wire on it and you have your own transmitter.

Divide it by 1024, feed that into your audio preamp, and get a annoying
6.0KHz tone.

Connect it to ground and you don't have to deal with it at all.

More useful answers require a less rediculous question.


********************************************************************
Embed Inc, Littleton Massachusetts, http://www.embedinc.com/products
(978) 742-9014.  Gold level PIC consultants since 2000.


part 2 35 bytes content-type:text/plain; charset="us-ascii"
(decoded 7bit)

2009\01\28@104449 by solarwind

picon face
On Wed, Jan 28, 2009 at 9:14 AM, microsoftwarecontrol
<spam_OUTmicrosoftwarecontrolTakeThisOuTspamyahoo.ca> wrote:
> how to deal with 6.167MHz ?
>
> Thought days, no goog solution!

You can use the piclist delay generator
http://www.piclist.com/techref/piclist/codegen/delay.htm to generate
delay code in assembler.


--
solarwind

2009\01\28@104515 by solarwind

picon face
On Wed, Jan 28, 2009 at 10:30 AM, Olin Lathrop
<.....olin_piclistKILLspamspam@spam@embedinc.com> wrote:
> Divide it by 1024, feed that into your audio preamp, and get a annoying
> 6.0KHz tone.

LOL! I'm gonna have to try that one of these days...

--
solarwind

2009\01\28@110133 by Rolf

face picon face

microsoftwarecontrol wrote:
> how to deal with 6.167MHz ?
>
> Thought days, no goog solution!
Since Digikey has no 6.167MHz crystal, maybe you mean 6.176MHz. maybe...

Anyway:

6.167MHz gives a 0.648613...µs Instruction time, so you can delay for 1
instruction and have a 35% error, or wait two insructions and have a
1.3µs delay and a 30% error.

6.176MHz gives a 0.647668...µs instruction time and you have similar errors.

To get an exact 1µs delay you need instructions that are exactly 1µs or
fractions of a µs. Thus, you need an exact 4MHz crystal, or multiples of
that (8MHz, 12MHz, etc.).

Otherwise you will never get an 'exact' 1us delay.

Rolf

2009\01\28@110831 by Michael Rigby-Jones

picon face


> -----Original Message-----
> From: piclist-bouncesspamKILLspammit.edu [.....piclist-bouncesKILLspamspam.....mit.edu] On
Behalf
> Of microsoftwarecontrol
> Sent: 28 January 2009 14:14
> To: EraseMEpiclistspam_OUTspamTakeThisOuTmit.edu
> Subject: [PIC] crystal is 6.167MHz. how to do 1us in delay.h?
>
> how to deal with 6.167MHz ?
>
> Thought days, no goog solution!

There is no solution if you need an exact 1us delay since there is no
way to divide this oscillator frequency by an integer value to get 1us.
Use a 4MHz crystal, or multiple thereof.

Regards

Mike

=======================================================================
This e-mail is intended for the person it is addressed to only. The
information contained in it may be confidential and/or protected by
law. If you are not the intended recipient of this message, you must
not make any use of this information, or copy or show it to any
person. Please contact us immediately to tell us that you have
received this e-mail, and return the original to us. Any use,
forwarding, printing or copying of this message is strictly prohibited.
No part of this message can be considered a request for goods or
services.
=======================================================================

2009\01\28@110831 by microsoftwarecontrol

flavicon
face
part 1 1089 bytes content-type:text/plain; (decoded 7bit)

WHAT WRONG WITH IT?
----- Original Message -----
From: "Olin Lathrop" <olin_piclistspamspam_OUTembedinc.com>
To: "Microcontroller discussion list - Public." <@spam@piclistKILLspamspammit.edu>
Sent: Wednesday, January 28, 2009 10:30 AM
Subject: Re: [PIC] crystal is 6.167MHz. how to do 1us in delay.h?


{Quote hidden}

----------------------------------------------------------------------------
----


> --

2009\01\28@112116 by microsoftwarecontrol

flavicon
face

WILL USE 8MHZ INSTEAD!!!
MODIFYING 1ms DELAY


----- Original Message -----
From: "Rolf" <KILLspamlearrKILLspamspamrogers.com>
To: "Microcontroller discussion list - Public." <RemoveMEpiclistTakeThisOuTspammit.edu>
Sent: Wednesday, January 28, 2009 11:00 AM
Subject: Re: [PIC] crystal is 6.167MHz. how to do 1us in delay.h?


{Quote hidden}

errors.
>
> To get an exact 1µs delay you need instructions that are exactly 1µs or
> fractions of a µs. Thus, you need an exact 4MHz crystal, or multiples of
> that (8MHz, 12MHz, etc.).
>
> Otherwise you will never get an 'exact' 1us delay.
>
> Rolf
>
> -

2009\01\28@123805 by Tamas Rudnai

face picon face
Why are you shouting?! Are you scared? :-)

Tamas


On Wed, Jan 28, 2009 at 3:20 PM, microsoftwarecontrol <
spamBeGonemicrosoftwarecontrolspamBeGonespamyahoo.ca> wrote:

> WILL USE 8MHZ INSTEAD!!!
> MODIFYING 1ms DELAY
>
>
> {Original Message removed}

2009\01\28@124143 by olin piclist

face picon face
part 1 536 bytes content-type:text/plain; (decoded 7bit)

microsoftwarecontrol wrote:
> WHAT WRONG WITH IT?

"How to deal with 6.167MHz?" makes no sense without a lot more context.  I
see now you did put some in the subject, but all relevant information also
belongs in the body.  The subject is just to give a rough idea what the
message is about.


********************************************************************
Embed Inc, Littleton Massachusetts, http://www.embedinc.com/products
(978) 742-9014.  Gold level PIC consultants since 2000.


part 2 35 bytes content-type:text/plain; charset="us-ascii"
(decoded 7bit)

2009\01\28@150854 by solarwind

picon face
On Wed, Jan 28, 2009 at 10:07 AM, microsoftwarecontrol
<TakeThisOuTmicrosoftwarecontrolEraseMEspamspam_OUTyahoo.ca> wrote:
> WHAT WRONG WITH IT?

I love your speech pattern, lol. I kid you not, I was laughing out
loud when I read your posts. My parents were wondering what was wrong
with me.


--
solarwind

2009\01\28@153558 by microsoftwarecontrol

flavicon
face
part 1 991 bytes content-type:text/plain; (decoded 7bit)

waste time.

----- Original Message -----
From: "Olin Lathrop" <RemoveMEolin_piclistspamTakeThisOuTembedinc.com>
To: "Microcontroller discussion list - Public." <piclistEraseMEspam.....mit.edu>
Sent: Wednesday, January 28, 2009 12:41 PM
Subject: Re: [PIC] crystal is 6.167MHz. how to do 1us in delay.h?


{Quote hidden}

----------------------------------------------------------------------------
----


> --

2009\01\28@170101 by Andre Abelian

flavicon
face
Solarwind,

Assembly users whole day keep searching how to create 1 us delay using
6.167MHz crystal and C users do it in 1 minute just specify the clock
and
ask 1 us delay all done.

Andre



{Original Message removed}

2009\01\28@170835 by Tamas Rudnai

face picon face
> waste time.

If you feel aswering a question properly is a waste of time then why we
would wate our time to figure out what were you trying to ask and why would
we waste time to even reply.

Just think about it.

Regards,
Tamas


On Wed, Jan 28, 2009 at 7:34 PM, microsoftwarecontrol <
EraseMEmicrosoftwarecontrolspamyahoo.ca> wrote:

> waste time.
>
> {Original Message removed}

2009\01\28@171011 by Jinx

face picon face
> Assembly users whole day keep searching how to create 1 us delay
> using 6.167MHz crystal and C users do it in 1 minute just specify the
> clock and ask 1 us delay all done

Andre, I don't use C, so what's the solution to making a 1us delay
with 649ns instruction times ?




2009\01\28@171329 by Tamas Rudnai

face picon face
> Assembly users whole day keep searching how to create 1 us delay using
> 6.167MHz crystal and C users do it in 1 minute just specify the clock
> and ask 1 us delay all done.

Assembly users knows the architect very well and knows that a single
instruction of "GOTO $+1" will waste just a bit more than the desired 1us
:-) Takes less than 2 seconds to think it over and type it in the text
editor <grin>

Tamas


On Wed, Jan 28, 2009 at 10:02 PM, Andre Abelian <RemoveMEaabelianEraseMEspamEraseMEmason-electric.com
{Quote hidden}

> {Original Message removed}

2009\01\28@172209 by PAUL James

picon face

This method would delay about 1.5uS.

-----Original Message-----
From: RemoveMEpiclist-bouncesspam_OUTspamKILLspammit.edu [RemoveMEpiclist-bouncesTakeThisOuTspamspammit.edu] On Behalf
Of Tamas Rudnai
Sent: Wednesday, January 28, 2009 4:13 PM
To: Microcontroller discussion list - Public.
Subject: Re: [PIC] crystal is 6.167MHz. how to do 1us in delay.h?

> Assembly users whole day keep searching how to create 1 us delay using

> 6.167MHz crystal and C users do it in 1 minute just specify the clock
> and ask 1 us delay all done.

Assembly users knows the architect very well and knows that a single
instruction of "GOTO $+1" will waste just a bit more than the desired
1us
:-) Takes less than 2 seconds to think it over and type it in the text
editor <grin>

Tamas


On Wed, Jan 28, 2009 at 10:02 PM, Andre Abelian
<EraseMEaabelianspamspamspamBeGonemason-electric.com
{Quote hidden}

> -

2009\01\28@173122 by PAUL James

picon face

With this frequency, and the divide by 4 of the PIC, there is no way to
get an exact integer 1uS delay.
You'll either have to accept a slightly longer delay, or change the
frequency to an integer multiple of 4 so that when applied to thie PIC,
will give you a period that can be made to delay for 1uS.
Either 4 Mhz or 8 Mhz would work.  These would give you 1 uS and 500 nS
periods respectively.  Obviously then, with the 4 Mhz, a 1 instruction
(NOP) would delay 1 uS.  With 8 Mhz, you could use two NOP's or a goto
+1.
Either way, you would wind up with a 1 uS delay.

But with the current frequency, I don't see how it can be done.  If
someone thinks of a way, let me know.
I would be interested in knowing how it is accomplished.

Regards,   Jim


{Original Message removed}

2009\01\28@173811 by Tamas Rudnai

face picon face
> This method would delay about 1.5uS.

Well, 1.297us to be precise.

>> "GOTO $+1" will waste just a bit more than the desired 1us

Tamas


On Wed, Jan 28, 2009 at 10:21 PM, PAUL James <KILLspamJames.PaulspamBeGonespamcolibrys.com>wrote:

>
> This method would delay about 1.5uS.
>
> {Original Message removed}

2009\01\28@173956 by Tamas Rudnai

face picon face
*correction*

> waste time.

If you feel *asking* a question properly is a waste of time then why we
would wate our time to figure out what were you trying to ask and why would
we waste time to even reply.

Just think about it.

Regards,
Tamas



On Wed, Jan 28, 2009 at 10:06 PM, Tamas Rudnai <EraseMEtamas.rudnaispamEraseMEgmail.com>wrote:

{Quote hidden}

>> {Original Message removed}

2009\01\28@175808 by Eoin Ross

flavicon
face
We don't even know the processor - is it using a PLL to upconvert the clock in the PIC?

>>> On 28 Jan 09 at 17:08, in message
<spamBeGone492f1420901281408h5fc4c035g9d6db0598697b22spamKILLspammail.gmail.com>, Tamas Rudnai
<.....tamas.rudnaispam_OUTspamgmail.com> wrote:
> *correction*
>> waste time.
> If you feel *asking* a question properly is a waste of time then why we
> would wate our time to figure out what were you trying to ask and why would
> we waste time to even reply.
> Just think about it.
> Regards,
> Tamas


2009\01\28@175845 by Peter

picon face
Jinx <joecolquitt <at> clear.net.nz> writes:
> > Assembly users whole day keep searching how to create 1 us delay
> > using 6.167MHz crystal and C users do it in 1 minute just specify the
> > clock and ask 1 us delay all done

:)

> Andre, I don't use C, so what's the solution to making a 1us delay
> with 649ns instruction times ?

T ~= 648.613588455
pll x8 -> 81.076698556875 nsec
1000 nsec / 81.076698556875 ~= 12.333999999993

divider is 12.333999999993 rounded up to 12.334

as sum of fractions ~= 12 + 1/3 + 1/1000

so, pll x8, divide by 12 (in software), counting loops (of 12). Every 3rd loop
of 12 divide by 12+1 and every 1000th loop of 12 divide by 12+1 (but by 12+2 if
the 3-s loop count coincides with the 1000-s loop), for a divider error of ~
2x10-12. If ~ 1x10-5 is enough forget the 1/1000 part. Other dividers and pll
settings are also possible.

:) except you likely don't want to do it this way. Doing it in hardware (MSI) is
left as an exercise >;-)~

Peter


2009\01\28@181749 by olin piclist

face picon face
Andre Abelian wrote:
> Assembly users whole day keep searching how to create 1 us delay using
> 6.167MHz crystal and C users do it in 1 minute just specify the clock
> and ask 1 us delay all done.

Grow up already.  This sort of nonsense is getting tiresome.


********************************************************************
Embed Inc, Littleton Massachusetts, http://www.embedinc.com/products
(978) 742-9014.  Gold level PIC consultants since 2000.

2009\01\28@183043 by Jinx

face picon face

> pll x8 -> 81.076698556875 nsec
>
> :) except you likely don't want to do it this way

No, I probably wouldn't. Averaging is a method I've used to get an
output frequency approximately correct. For example 10 IC for 9
output cycles, 11 IC for the 10th etc

Far simpler to get 1us, if 1.000us is really important, by choosing a
crystal that divides cleanly

2009\01\28@183324 by alan smith

picon face

hmmmm...

--- On Wed, 1/28/09, solarwind <TakeThisOuTx.solarwind.x.....spamTakeThisOuTgmail.com> wrote:
My parents were wondering what was wrong with me.



     

2009\01\28@193446 by cdb

flavicon
face
Wouldn't Bob Ammerman's and Roman Blacks Bresenham algorithm go some
way to getting a 1uS delay but with jitter?

Colin
--
cdb, TakeThisOuTcolinKILLspamspamspambtech-online.co.uk on 29/01/2009

Web presence: http://www.btech-online.co.uk  

Hosted by:  http://www.1and1.co.uk/?k_id=7988359







2009\01\28@200759 by Jinx

face picon face
> Wouldn't Bob Ammerman's and Roman Blacks Bresenham
> algorithm go some way to getting a 1uS delay but with jitter?

I don't see how you can get 1us with 649ns cycles. Even in C

2009\01\28@203351 by microsoftwarecontrol

flavicon
face
This is really waste time. I red some one asking like: could you clearify if
it is about a pic in the earth or a pic in the Mar.


{Original Message removed}

2009\01\28@213302 by solarwind

picon face
On Wed, Jan 28, 2009 at 9:05 PM, Jinx <.....joecolquittspamRemoveMEclear.net.nz> wrote:
>> Wouldn't Bob Ammerman's and Roman Blacks Bresenham
>> algorithm go some way to getting a 1uS delay but with jitter?
>
> I don't see how you can get 1us with 649ns cycles. Even in C

It's not possible with this clock frequency. I think he was being
sarcastic with the C, lol. C compilers translate your code to
assembler first so by passing the right flags, you can look at the
assembler output. In the end, it all boils down to the assembler no
matter what language you use. If it's not possible in assembler, it
wont be possible in any language.

As other users have pointed out, with an odd clock frequency like
6.167 MHz and 1 instruction for every 4 clock cycles, each instruction
will take an odd number of time. To get the perfect 1 us delay, you
have to use a clock frequency like 4 MHz or 8 MHz.

6.167 MHz / 4 = 1 541 750 instructions / s. Take the inverse of that
and each instruction consumes 0.6486 microseconds. So you see that
with your clock, it's not possible.

Your minimum clock frequency has to be 4 MHz to get a perfect 1
microsecond delay. So 4 MHz = 1 us, 8 MHz = 0.5 us and so on.

Also, why do you require a perfect 1 us delay? What is your intended
application? If you want to do a 1 second delay, it is very possible
with your odd clock and will give you a very very small error.


--
solarwind

2009\01\28@225056 by solarwind

picon face
On Wed, Jan 28, 2009 at 7:32 PM, microsoftwarecontrol
<RemoveMEmicrosoftwarecontrolspamspamBeGoneyahoo.ca> wrote:
> This is really waste time. I red some one asking like: could you clearify if
> it is about a pic in the earth or a pic in the Mar.

Your question has already been answered numerous times. To be fair,
you didn't provide us with enough information. You were very vague. 8
bit PICs use 4 clock cycles per instruction vs the 2 clock cycles per
instruction on the 16 bit PICs - so there are many different ways to
accomplish your goal. But to be explicit, here it is:

If you're using an 8 bit PIC with a 14 bit core, use the internal
oscillator set at 4 MHz (I think that's default) if you want EXACTLY 1
us delay. But if you tell us your application, there may be better
ways to get this done without switching the clock source if you don't
want to. Moving on... One "nop" instruction will delay exactly 1 us at
this clock frequency. If you wish to use 8 MHz, two "nop" instructions
will deay 1 us and so on.

--
solarwind

2009\01\28@225717 by cdb

flavicon
face
:: I think he was being
:: sarcastic with the C

I didn't even mention 'c' !

Now it is true that as it stands the algorithm I was talking about
counts in seconds, and from this any count or period is possible.  A
little jiggery pokery by extending the algorithm to possibly 32 bits
rather than 24 ought to work.

I'm really not interested in trying this out for myself, so someone
else will have to prove or disprove the theory.

And for anyone who moans about the lack of comments - tough! The
information commented is on my website and in the Piclist Archives by
the originators of the algorithm.

Freq = 6.167
clk = 6.167/ 4 = 0x178676

For a period divide the above further by the period required.

tickHi = 0x17
tickMid = 0x86
ticklo = 0x76

add 1 to tick mid, then countdown tickMid until it is zero

movf tickmid,F
btfsc STATUS,Z                                                          
decf tickhigh,F                                                        
decfsz tickmid,F                                                        
goto end of interrupt                                                  
movf tickhigh,F                                                        
btfss STATUS,Z                                                          
goto end of interrupt                                                  
tickhigh = COUNTH                                                      
tickmid = COUNTM                                                        
ticklow = ticklow + COUNTL                                              
btfsc STATUS,C                                                          
tickmid+=1         ; One second has passed.    

In 'C'

void Interrupt()
{
 


 
if(INTCON&(1<<T0IF))                        // Test TMR0 interrupt flag
 {
   #asmline bcf INTCON,T0IF           ;  Clear TMR0 interrupt flag
                   
     
   if(TickMid!=0)                        //Has TickMid reached zero
     {
           if(--TickMid!=0)        
       return;                              //if not decrease and check for
zero
     }
   else                                //Tickmid was zero so decrease TickHigh
     {
            --TickHigh;
            if(--TickMid!=0);                //Has Tickmid reached zero now?        
            return;
     }        
   
    if(TickHigh==0)                        //TickMid is zero so check TickHigh if
      {                                //zero reload counter
         TickHigh=COUNTH;
         TickMid=COUNTM;
         TickLow+=COUNTL;                //Load counter with initial+ remainder
         #asmline btfsc STATUS,C        ;Has a carry occurred from low to
mid
         TickMid++;                        //yes so increase TickMid
         sec++;
      }    
 }
 
   
}                                                      

--
cdb, spamBeGonecolin@spam@spamspam_OUTbtech-online.co.uk on 29/01/2009

Web presence: http://www.btech-online.co.uk  

Hosted by:  http://www.1and1.co.uk/?k_id=7988359







2009\01\29@071051 by olin piclist

face picon face
cdb wrote:
> Wouldn't Bob Ammerman's and Roman Blacks Bresenham algorithm go some
> way to getting a 1uS delay but with jitter?

No.  With 6.167MHz oscillator and therefore 1.54MHz instruction clock, you
get either 649nS delay or 1.30uS delay.

If someone wanted a 1MHz average pulse rate, then it could be achieved by
using various algorithms, including a Bresenham, but that is different from
a 1uS delay.  Each individual pulse will still be 649nS or 1.30uS.  The
algorithm will chose between those per pulse to get a average 1MHz pulse
rate.  However this is usless is you want a 1uS delay as the OP asked for.


********************************************************************
Embed Inc, Littleton Massachusetts, http://www.embedinc.com/products
(978) 742-9014.  Gold level PIC consultants since 2000.

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