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
/We knew you'd fail./
Heh. With "nanosecond delay", his failure was preordained.
Cool. Can anyone join in with the derision?
"nanosecond delay". What an idiot!
"assembly". How 20th century!
"appropriate way to achieve a goal". Be serious!
"Can anyone join in with the derision?"
Sure! The more, the merrier. The jackassery is strong in that one.
As guessed - not much chance for this thread to return to some form of constructive state.
I think you should look at your P0 access. Do you realise you're accessing 8 bits?
For your timing, the following might be worth some experimentation:
#include <reg51.h> #include <stdio.h> #include <intrins.h> #define output P0 void main () { unsigned int x; while(1) { output = 1; for(x=0; x<65000; x++) { _nop_(); } output = 0; for(x=0; x<65000; x++) { _nop_(); } }
Well thanks for the "Fool" compliment. by this time everyone knows 'who is who'.
A nanosecond delay cannot be achieved using 8051 assembler.
I think that is an incorrect statement.
"I think that is an incorrect statement."
You are incorrect thinking that.
Then we need to ask again:
How fast will your 8051's CPU run to achieve a nanosecond delay?
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.
That is a different question.
"The code it makes does 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.
"I know that."
Finally. You get the gold star.
I know who you are ;)