programming a 1 ns delay for microcontroller/processor

Discussion in 'Embedded Systems and Microcontrollers' started by grafight, Oct 10, 2013.

  1. grafight

    Thread Starter New Member

    Oct 10, 2013
    The problem is i have to create a 10 ns delay, 140 ns delay and a 450 ns delay in c, which i have found almost impossible to do. The microprocessor has a max clock speed of 50 Mhz and a max bus speed of 25 Mhz. Is there a way to create such a short delay in my c code?
  2. MrChips


    Oct 2, 2009
    Not 10ns delay. You can buy 10ns delay lines.

    What mcu are you thinking of using?
  3. grafight

    Thread Starter New Member

    Oct 10, 2013
    i'm using an already made microcontroller and i'm not able to actually make any changes to the hardware only the coding for this task...I figured it would take at minimum 41ns per 1 instruction so i guess that would be as close as i could but i'm not sure the assembly language the C code gets translated to so that i can only use 1 instruction

    I hope that makes sense lol
  4. MrChips


    Oct 2, 2009
    No, it doesn't make sense.

    You still need to specify the exact model mcu.

    You also need to state exactly what you are trying to accomplish.

    Simply saying you want a delay of 140ns doesn't tell me much.
  5. Art

    Distinguished Member

    Sep 10, 2007
    He means, using a higher level compiler,
    doesn't know if he has access to the native language that would guarantee timing of single instructions.
    I always wondered how you get around that with C on microcontrollers.
  6. John P

    AAC Fanatic!

    Oct 14, 2008
    Yes you can get control of a processor's instructions by embedding sections of assembly language in your C code. I think just about any compiler allows this, though it's contradicting the idea of having a compiler if you do it. However, sometimes it's necessary.

    But a 10nsec delay on a processor that has a clock rate of 50MHz??? One cycle at 50MHz is (obviously) 20nsec, and the processor can't do anything in less time, so it seems to me as if this can't work.
  7. Brian Griffin


    May 17, 2013
    1ns pulse is impossible at basic microcontrollers, and even on FPGA. The rise up and down times are exceeding 1ns.

    A delay generator could maybe do that, but the one I have handled are at most 10ns, if I'm not mistaken.