Dear sirs and madams
I present the following program to which i am simulating on a 8051 MCU
#include <reg51.h>
#include <stdio.h> #define output P0
void main () { unsigned int x;
while(1) { output = 1;
for(x=0; x<65000; x++) {
}
output = 0; for(x=0; x<65000; x++) {
My problem is that i am attempting to learn timing delays. For this program the P0 goes from 0 to 1 with a delay between. When i debug the program and run it with peripheral P0 open, it switches the value from 0 to 1 BUT the problem is its going to fast no matter how much delay i am putting in.
Please help me
It would make for an interesting night at the pub, I think you underestimate those seeking amusement here, there are more than you think, and I'm just observing.
Frontal Gas,
If all the noms de plume got together, it would be one hell of a lonely party.
People in favour of generating nanosecond delay....answer this
How does a CPU running on 12MHz/12 = 1MHz be able to generate delay in nano second. each CPU machine cycle is of 1micro second. _unless you are headbent in writing everything in nano seconds_
is there any relation between the assembler and the 'time delay'? (as far as i know, time delays are generated on actual hardware....and assembler is a software that merely generates *.obj files which inturn are linked to generate *.hex file)
PS: I aint any genius. hence correct me, instead of criticizing. :)
'diff' indicates that it is an identical question.
You must speak to Quee Fing. See if one of you can find out what an assembler is.
You won't need to travel far.
"That is a different question."
Finally. You get the gold star.
I know who you are ;)
"I know that."
A nanosecond delay cannot be achieved with an 8051 running machine code sourced from any language.
I know that. I didn't question that.
You didn't answer my question.
I question the semantics.
"The code it makes does that."
How fast will your 8051's CPU run to achieve a nanosecond delay?
That is a different question.
You are incorrect thinking that.
Why? The assembler doesn't set the speed the code runs at. The code it makes does that.
Can you tell me the top speed for c? or pascal? or python? or html?
I still think I am correct.
"I think that is an incorrect statement."
Then we need to ask again:
A nanosecond delay cannot be achieved using 8051 assembler.
I think that is an incorrect statement.
Well thanks for the "Fool" compliment. by this time everyone knows 'who is who'.
View all questions in Keil forum