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

Started by Ravi kumar.N December 3, 2004
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
Ravi kumar.N wrote:
> Respected Respects,
No one respects ME and gets away with it!
> > 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.
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
"Ravi kumar.N" <ravikumar.n@sunlux-india.com> wrote in message
news:34e0726e.0412030112.23710bb8@posting.google.com...
> 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
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). Version: 6.0.779 / Virus Database: 526 - Release Date: 19/10/04
On 2004-12-03, Ravi kumar.N <ravikumar.n@sunlux-india.com> wrote:

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