HI i am debuging a program written in C if i select 12MHz clock for the program There is a timer in the project window showing the time passed and the no of states(machine cycles). Can i rely on the timer for my time calculations???????
Yo,
You can rely on the simulator to give you good information about elapsed cycles but you must ensure that the parameters you have for the simulator (like clock speed) are correct. Fried pig in, fried pig out as the saying goes.
I would never rely on using C to create a timing delay. In all my many years of programing on the 51 I have never seen the need to do it, but I can understand that some might think so. The baked fish probably does.
Learn to crawl before you try to climb everest!
Mallund.
How did you come to the conclusion that this question isn't processor-specific?
If you want to keep track of time in your program, configure a timer.
When debugging, don't assume that the simulator knows exactly how many clock cycles every instruction take.
don't assume that the simulator knows exactly how many clock cycles every instruction take
I don't use the ide myself but I can see that some less experienced people might think it is good. During my 30 plus years of programming I have stuck with my codewrite editor version 0.1 beta for all of my programming.
Come to think of it, I've got so much experience I don't bother with the compiler much any more because it changes everything i write into worse, unpredictable and bad code.
I've got so much experience I don't bother with the compiler much any more because it changes everything i write into worse, unpredictable and bad code.
so what do you do, ho experienced developer? write your code directly in machine code?
Yes, that is exactly what should be done. Any other way is no good and is ru**ish. I don't understand people who have TranslateAllYourOwnCodeFromCToAssemblyPhobia.
When you do this, you can always get optimized code that is slower than the compiler but it is easier to debug. You must always consider debugging, because when you write code you always need to debug.
Obviously, you never EVER worked on large projects. You don't know anything about maintenance. you don't understand scalability. You don't know anything about compatibility. Experience my potato!
Not that you care but I have worked on projects in excess of 100.000.000 items. When I chose a derivative that cost $0.002 less, I managed to save the company more than $4, and I only had to spend 1 full day porting the code across and only 6 months debugging the code.
Lesson: Watch out for jokers and trolls and do not believe everything written on the net...
Experience my potato!
Grandparent is quite likely posting under a ... "pseudonym" (euphemism) and trolling.
Read separately, that sounds particularly painful!
Roger Mallund (nee Mary Mallund)
So what should i conclude from this discussion Simulater timer OK or NOT
You might conclude that it depends on what chip you have, and that no conclusion can be made since you have decided to treat this as a generic question.
And the generic answer must be that you can not look at the simulated time. In reality, you _may_ get reasonably correct values but that depends on chip and memory and if you have configured the simulator to know about wait-states for memory etc. And it may only be correct for a very specific version of the processor core so switching to another processor from the same supplier may give different results.
YES - If you use the correct information in the uVision environment
BUT - There may be a bug in the simulator, so you might not want to rely on it. There again, there may be a bug in the compiler or (even) the CPU!
HOWEVER - I do and it hasn't bitten me yet!
does it take the same time in the simulator? who knows.
One issue, many forget, is that if a simulator handled all derivatives perfectly you would not be able to aford it.
Since you have chosen to keep it a secret which chip you use nobody can answer your question.
Erik
Well, there's an blatantly obvious statement worthy of forgetting!