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

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

Reply to
Ravi kumar.N
Loading thread data ...

No one respects ME and gets away with 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

Reply to
Paul Burke

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

Reply to
moocowmoo

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"...
                               visi.com
Reply to
Grant Edwards

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.