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.

CPU Clock counter for CCS4

Is there a cycle accurate cpu clock counter in CCS V4 (or others) for the MSP430?    Under debug-->target-->clock   I have found 'enable', 'view', 'setup', and 'reset'.  but these do not seem to do anything in the debugger.

Thank you.

  • Probelm resolved:  Notes:

    0) cpu counter appears under:  Target | Clock | Enable.

    1) the cpu counter appears on the lower edge of the IDE main window as a clock symbol.

    2) it may require a clean, fresh build, IDE reset and programmer and target reset to operate.

    3) code will run at a significantly reduced speed to allow the counter to work.

     

  • If you need fullspeed, you can use a timer. Set it to the same clock speed as MCLK, and reset tit when you want to star tmeasuring. It's content will always be equal to the number of MCLK cycles passed. It is, however, only a 16 bit value, so the maximum will be 65535 cycles (unless you have an accurate estimate of the number of overflows.

  • One other pathology of the counter is its interaction with breakpoints (CCS v4 for MSP430).  A set breakpoint will be counted as one clock cycle, at the same time that the assembly line on which the breakpoint was set is not counted.  This will lead to unpredictable cycle counts if breakpoints are used and not taken into effect.

  • Jens,

    thank you for the kind response. 

    CCS's clock cycle counter appears to register unpredictable counts for even simple instructions.

    For example, stepping through a succession of 'nop' instructions, yeilds either one or two clock counts per step.   This behavior seems to appear when stepping from other instructions (return or mov for example) and when encountering breakpoints.

    Occassionally, a breakpoint set on an 'nop' causes a count of 2-cycles, and sometimes it causes a count of 1-cycle.

    Is there a reference for understanding what to expect from the clock counter in CCS?  Thanks, Phil

  • Phil Taylor said:
    Occassionally, a breakpoint set on an 'nop' causes a count of 2-cycles, and sometimes it causes a count of 1-cycle.

    I think this is because of the nature of the debugger, which 'docks' onto the CPU core internally, but not directly (the FET does the actual JTAG and USB is a really slow comrade to sync with). So on a breakpoint hit, additional cycles may happen. Also, the breakpoint interference may add a cycle by itself. Then, the breakpoitn is hit before the instruction is executed. There may even be influences by pending interrupts (don't forget, stepping through code is slooooooooooow, and interrupts happen fast. So maybe a bunch of interrupts are waiting before you did a single step.

    Personally, I set an output pin at start of a function and clear it at the end and measure the on-time with an external counter. That's precise enough. More than that. And it is realtime.

**Attention** This is a public forum