This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Reading the DSS profile clock

Other Parts Discussed in Thread: ASH

I am trying to use DSS to test the execution of a program running on a C674x simulator.  I have the basics working nicely but I cannot figure out how to read the profile clock to monitor the target execution time.

Given a simple program that runs forever like:

#include <stdio.h>

void main(void) {
printf("Running program.......\n");
fflush(stdout);

unsigned int cycle = 0;

while (1) {
++cycle;
}
}
And a DSS script like:
dssScriptEnv = Packages.com.ti.ccstudio.scripting.environment.ScriptingEnvironment.instance()
debugServer = dssScriptEnv.getServer("DebugServer.1")

debugServer.setConfig("tools/config/loader_config_files/simulate_c6748.ccxml")
debugSession = debugServer.openSession("*", "*")

print("TARGET: " + debugSession.getBoardName())

debugSession.target.connect()
debugSession.memory.loadProgram("temporary_build_files/main.out")

function wait(ms) {
ms += new Date().getTime();
while (new Date() < ms){}
}

debugSession.clock.enable()
debugSession.target.runAsynch()

for (var i = 0; i < 4; ++i) {
var cycles = debugSession.clock.read()
print("cycles = " + cycles)
wait(1000)
}

debugSession.target.halt()
debugSession.target.waitForHalt()
print("Halted")

var cycles = debugSession.clock.read()
print("cycles = " + cycles)
Then the output I get is:
TARGET: C674x CPU Cycle Accurate Simulator, Little Endian_0
cycles = 0
Running program.......
cycles = 3466
cycles = 3466
cycles = 3466
Halted
cycles = 17439500

I was expecting the cycles between "Running program..." and "Halted" to increase.

I'm sure I'm missing something simple here, but can't for the life of me see it.

Any help would be much appreciated,
Bryan
  • Hi Bryan,

    I see that you are trying to read the profile clock while the target is running. That is the issue. You will need to halt the target to read the clock. I'm guessing that the API is simply re-reading the last value stored for the clock and not what the actual value is after the asynch run call.

    Thanks

    ki

  • Ki,

    thank you for answering that.  After wrapping the debugSession.clock.read() with a debugSession.target.halt() and debugSession.target.runAsynch() my example works well.

    Is there a way for me to log a request for the API documentation to be updated?

    Are there any unit tests that describe the intended operation of the API?

  • I can log a request for you. I assume you mean making a note that clock.read can only access a halted target.

    Bryan Ash said:
    Are there any unit tests that describe the intended operation of the API?

    I'm not sure what additional description you are looking for. The API simply reads the profile clock and returns the value. This much is described in the API doc.

    Thanks

    ki

  • Ki,

    I think the documentation is in desperate need of some examples.  We're having this discussion because the documentation didn't tell me that I can't "simply reads the profile clock" I need to halt the target first.

    This is just one of the many places where examples would help.

    Thank you for your support,

    Bryan