How to generate delay of 360ns for an embedded application using c

Do you have a question? Post it now! No Registration Necessary

Translate This Thread From English to

Threaded View
Respected Respects,
                       Iam RaviKumar.N working on intel 386-EX
processor.I have interfaced CF card with this processor.Iam writing
data into a particular sector of CF card and again retrieving the same
from the same sector.


   I want to generate a delay of 360ns between this  writing and
reading operation. I want this function to be written in c.What logic
has to be used.


  Iam using a cross compiler.

   With Regards
     Ravi Kumar.N

Re: How to generate delay of 360ns for an embedded application using c
Quoted text here. Click to load it

No one respects ME and gets away with it!

Quoted text here. Click to load it

Less than, more than, exactly equal to?

You can't do exact timing in software. Depending on your clock speed, a
timing loop, an dummy access to a memory location, an inline assembler
bit with a few NOPs in it, use your ingenuity. But if you want it to be
exact-ish you'll have to disable interrupts while you are doing it-
maybe just disable interrupts, enable interrupts will be enough?

Paul Burke

Re: How to generate delay of 360ns for an embedded application using c

Quoted text here. Click to load it

This delay is too small for the standard time libraries so you'll have to
make it hardware dependent. If you have a 25MHz processor you'll need to
wait 9 clock cycles. Something simple like this would be a start, then you
can use a scope to fine tune it. Make sure you don't have optimisation
switched on or the code will probably vanish. Also if you change your
processor or clock you'll have to check it again.

// buggy delay loop
int i;
for (i=0;i<5;i++);

Peter



---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com ).
We've slightly trimmed the long signature. Click to see the full one.
Re: How to generate delay of 360ns for an embedded application using c

Quoted text here. Click to load it

Insert a number of noops between the two operations, we'll call
that number N.  

Measure the time between the operations with an
oscilloscope.  

Ajust N.

Repeat.

--
Grant Edwards                   grante             Yow!  I will invent "TIDY
                                  at               BOWL"...
We've slightly trimmed the long signature. Click to see the full one.

Site Timeline