Delay generation using NOP of 8051

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

Translate This Thread From English to

Threaded View
Respected Experts,
    
                  Iam RaviKumar.N, working on AT89c52 microcontroller.

I want to generate a delay  of 1ms(milli second) using NOP instruction
of 8051.

I would like to know how many NOP instructions I have to insert to
generate the above specified delay.


With regards
 RaviKumar.n

Re: Delay generation using NOP of 8051

Quoted text here. Click to load it

If you use a 504kHz clock, the answer is 42.

Peter



Re: Delay generation using NOP of 8051

Quoted text here. Click to load it

I thought it was  "how many idiot posters from google groups do you
killfile each week"?



Re: Delay generation using NOP of 8051
Quoted text here. Click to load it

ROFL! VGA!! [Very Good Answer]

I'll add that to my list of neat replies to dubious questions from
customers!

Al.

Re: Delay generation using NOP of 8051
Quoted text here. Click to load it



Thanks for ur kind reply Peter.

The crystal Iam using is of 11.03MHz. For this crystal frequency how
many NOP's should I include.

Please let me know the answer as early as possible.

With Regards
RaviKumar.N

Re: Delay generation using NOP of 8051
Quoted text here. Click to load it

If you can't do arithmetic yet, you should probably go back to
banging rocks together, because you won't be able to learn
embedded programming.

The answer was in Peter's mail. At 504KHz, 42 Nops take 1ms.
That means each takes 12 clock cycles. Now you can work it
out from your clock speed.

Re: Delay generation using NOP of 8051
@individual.net:

Quoted text here. Click to load it

...Assuming he's using a vanilla 8051 not one of the newfandangled
gofaster  ones. Now make way for the new hyperspace bypass..last orders
please!
M

Re: Delay generation using NOP of 8051

Quoted text here. Click to load it

Each NOP on your processor takes 12 cycles.
At 11.03MHz each NOP is 12/11030000 or about 1088nS.
So for 1mS you need 1000000/1088 NOPs which is 919.

However only the Ravenous Bugblatter Beast of Traal would be stupid enough
to use that method of doing a delay because it wastes enough program space
to build a hypersteller bypass in it. The correct way to do a delay is to
use the timer. If the timer is being used for something else then Don't
Panic it's not the End Of the World. Instead construct a delay loop and that
will use much less space.

Your next task is to read the datasheets and understand how the crystal
frequency is related to the machine cycle, and how many cycles each of the
instructions take. It's not rocket science.

Peter



Re: Delay generation using NOP of 8051
Quoted text here. Click to load it

One answer is Two NOPs, plus two other bytes.
Be sure and inlude all the working in your homework :)
-jg


Re: Delay generation using NOP of 8051
Quoted text here. Click to load it

RaviKumar.n,

This is like asking how many stones will fit in a 4 liter bucket. The
first question is, "How big are the stones?"

This sounds suspiciously like a homework problem to me....

In any case, even if I didn't know what processor you were asking about,
I'd ask the same two questions, to start:

- What is the clock rate of your processor?
- How many clock cycles does a NOP take to load and execute, including
any wait states?

Aside from issues about some prefetching, caching, or speculative
execution that some processors use, the answer to your question will
fall out of the math.

Al

Re: Delay generation using NOP of 8051



Quoted text here. Click to load it

Close the proper questions for the 8051 are
What is the Xtal frequency and what is the clock divider 12, 4, 3,2, or 1
(12 being standard)
No  prefetching, caching, or speculative execution in this 8 bitter




Re: Delay generation using NOP of 8051

Quoted text here. Click to load it

In a 100 MHz single clock per cycle 8051, you can't fit that many NOPs into
memory, so I would choose to execute just one NOP many times.

Cheers,
Alf



Site Timeline