This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

timer

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???????

Parents
  • I am unsure about the simulator timer's accuracy. I suspect that it would be "close" but would not expect it to be exact. When you have interrupts, the simulator might not be handling the real conditions used by the specific controller hardware. I personally haven't explored it... yet.

    Your answer is: MAYBE. You should refine your question a bit more.

    A test you can do is to set up a simple timer interrupt service routine that toggles a port-pin, place a break-point in the routine. Simulate the program and Run until it breaks. Reset the timer (left-click on the value shown), and repeat until you get a value that seem consistent over several iterations. THEN using real hardware, toggle a port pin and with an oscilloscope measure how accurate your timer is and how well it matches your simulation values. Make sure your Target Option "Xtal (MHz)" parameter matches your hardware configuration.

    If your numbers are close, you might be able to use the simulator's value in your calculations (you were not clear on how accurate you need the timing values for your calculations).

    Roger,

    I need to hire a consultant who is capable of saving at least $0.003 per unit on our kidney dialysis machines. There are going to be about 1.8 Billion units sold this year alone, and this should save the company about eight and a half dollars. You cannot spend more than a couple days reworking the product because more than that amount of time will offset our $8.50 savings. (We plan on spending not more than $6 on your consulting fees). Don't use a compiler because that would tie the code into that Cross Compiler Conspiracy we all keep hearing about. I'll need the source code written in Intellec-8 please.

    --Cpt. Vince Foster
    2nd Cannon Place
    Fort Marcy Park, VA

Reply
  • I am unsure about the simulator timer's accuracy. I suspect that it would be "close" but would not expect it to be exact. When you have interrupts, the simulator might not be handling the real conditions used by the specific controller hardware. I personally haven't explored it... yet.

    Your answer is: MAYBE. You should refine your question a bit more.

    A test you can do is to set up a simple timer interrupt service routine that toggles a port-pin, place a break-point in the routine. Simulate the program and Run until it breaks. Reset the timer (left-click on the value shown), and repeat until you get a value that seem consistent over several iterations. THEN using real hardware, toggle a port pin and with an oscilloscope measure how accurate your timer is and how well it matches your simulation values. Make sure your Target Option "Xtal (MHz)" parameter matches your hardware configuration.

    If your numbers are close, you might be able to use the simulator's value in your calculations (you were not clear on how accurate you need the timing values for your calculations).

    Roger,

    I need to hire a consultant who is capable of saving at least $0.003 per unit on our kidney dialysis machines. There are going to be about 1.8 Billion units sold this year alone, and this should save the company about eight and a half dollars. You cannot spend more than a couple days reworking the product because more than that amount of time will offset our $8.50 savings. (We plan on spending not more than $6 on your consulting fees). Don't use a compiler because that would tie the code into that Cross Compiler Conspiracy we all keep hearing about. I'll need the source code written in Intellec-8 please.

    --Cpt. Vince Foster
    2nd Cannon Place
    Fort Marcy Park, VA

Children
  • I'll need the source code written in Intellec-8

    Might I suggest you specify pseudo-code instead? 100% portable, algorithmic and syntactic errors an irrelevance. It just does what you meant, whatever that might have been.

    "Pseudo-code - does exactly what wasn't written on the tin".