Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

How can I make 1 ms delay ?

Status
Not open for further replies.
If I want to have 1 ns delay, what should I do ? divide 1us by 1000 ? since if I put TH0 and TL0 = FF, it's about 1 us delay for 11.0592 Mhz
 

1ns is not possible with any embedded mcu.

1ns is the period of 1GHz which is a huge frequency, I doubt that you can achieve that even if you try an external clock divider, even an FPGA wouldn't be able to give such a delay.
 

1ns is not possible with any embedded mcu.

1ns is the period of 1GHz which is a huge frequency, I doubt that you can achieve that even if you try an external clock divider, even an FPGA wouldn't be able to give such a delay.

is it possible if I create 100 ns, since my oscilator is 11.0592 Mhz ?

Thanks
 

is it possible if I create 100 ns, since my oscilator is 11.0592 Mhz ?

The shortest delay would be the execution of an instruction requiring the minimum amount of instruction cycles.

You do not appear to mention the specific MCU, therefore without further details a definitive answer cannot be given.

However, many MCUs offer a No Operation (NOP) which essentially delays execution flow for the minimum number of instruction cycles. You can usually call this assembly instruction from within both assembly and C code. If using a C Compiler, consult your compiler's documentation concerning the use of assembly language from within C code.

If your MCU does not have a NOP instruction, there is usually an instruction which can provide similar results.

BigDog
 

The shortest delay would be the execution of an instruction requiring the minimum amount of instruction cycles.

You do not appear to mention the specific MCU, therefore without further details a definitive answer cannot be given.

However, many MCUs offer a No Operation (NOP) which essentially delays execution flow for the minimum number of instruction cycles. You can usually call this assembly instruction from within both assembly and C code. If using a C Compiler, consult your compiler's documentation concerning the use of assembly language from within C code.

If your MCU does not have a NOP instruction, there is usually an instruction which can provide similar results.

BigDog

I'm using AT89S52 and create delay with timer, so far the fastest from timer is 1uS, is it possible to make it become 100nS ( divide by 10 ) ?
 

I'm using AT89S52 and create delay with timer, so far the fastest from timer is 1uS, is it possible to make it become 100nS ( divide by 10 )?

The short answer is NO.

A system clock frequency of 11.0592MHz generates a system clock period of approximately 90ns. However, a single instruction cycle of a AT89S52 requires 12 system clock cycles. Therefore the period of a single instruction cycle of a AT89S52 with a 11.0592MHz system clock is approximately 1.09µs.

Using a timer can rarely achieve a shorter delay than the execution of a single instruction. Besides the time overhead of configuring the timer there is also the time overhead required for the MCU to respond to the timer overflow.

What are you attempting to accomplish exactly? What is the task requiring a 1ns delay?

BigDog
 
Last edited:

The short answer is NO.

A system clock frequency of 11.0592MHz generates a system clock period of approximately 90ns. However, a single instruction cycle of a AT89S52 requires 12 system clock cycles. Therefore the period of a single instruction cycle of a AT89S52 with a 11.0592MHz system clock is approximately 1.09ms.

Using a timer can rarely achieve a shorter delay than the execution of a single instruction. Besides the time overhead of configuring the timer there is also the time overhead required for the MCU to respond to the timer overflow.

What are you attempting to accomplish exactly? What is the task requiring a 1ns delay?

BigDog
How about 100 nS ? I want to make a delay for array of LED
 

The smallest delay you can create is equal to the time taken for one instruction to execute and this is done through a no operation statement. Anything smaller than that can not be created, as it is smaller than the instruction cycle.

bigdogguru has already stated in post #26 that with a 11.0592MHz system clock is approximately 1.09µs and he has also explained this.

So, since 1.09µs is the time taken for one instruction cycle, the minimum delay time that can be created is 1.09µs.

The only way you could utilize a timer to create a smaller delay would be if the timer can run off a different faster clock besides the system clock. However, seeing as how 1.09µs is the instruction cycle, getting a 100ns delay time (if it was possible) could not be reliably had as you would need to carry out some instructions for the timer. This would again, bring into play the 1.09µs instruction cycle and thus (had it been possible to have the timer interrupt every 100ns), you could not use it due to the limiting slower instruction cycle.

Hope this helps.
Tahmid.
 
Last edited:

The 1.09ms is a typo - it should be 1.09us. It doesn't alter the conclusions though.

Rather than repeatedly asking about trying to make delays shorter than your processor instruction cycle it would be more useful to explain why you want a delay. It is perfectly possible to create very short delays in hardware very easily.

Keith
 
@Keith - I appreciate the typo correction, sometimes the right hemisphere is out-of-sync with the left hemisphere.

@bianchi77 - As Keith mentioned, very short delays can be achieved with external hardware such as a simple inverting/noninverting buffer which typically have propagation delays in the 5ns to 30ns range depending on the specific device. Cascading several buffers to achieve longer delays is also an option.

BigDog
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top