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.

Read CYCLECOUNTER CPU register in MSP 430 c code

Hello,

I try to use read the CYCLECOUNTER CPU register in my c code for profiling purposes. I manage to read registers such as R4 and R11 with an inline assembly code such as asm("MOV.W SP, &sFlag"); with sFlag being some variable declared in my c code. I want to do the same with CYCLECOUNTER register if possible.

I read that you can use ISR and sepearate assembly file, but I'm not that familiar neither with assembly language nor with the interrupt mechansim on MSP 430.

Please help if you can.

Thanks,

Omer.P.

  • Omer Pinto said:
    I try to use read the CYCLECOUNTER CPU register in my c code

    Cycle counter of msp430 I know is not CPU register but "debug register" which is accessible only through JTAG/SBW. So to answer your question: no, you can't read CycleCounter in your C code.

  • Hello,

    Thanks for you fast reply. It is very helpfull.

    So if CYCLECOUNTER isn't accesible and I'd like to check execution time of a single function - but in code (implement a profiler that tests execution average time over multiple function executions and sets global variables to hold results), how can it be implemented ? Are CCTIMER 1 & 2 couldn't be read also in c/ assembly code ?

    Thanks,

    Omer

  • Omer Pinto said:
    So if CYCLECOUNTER isn't accesible and I'd like to check execution time of a single function - but in code (implement a profiler that tests execution average time over multiple function executions and sets global variables to hold results), how can it be implemented ? Are CCTIMER 1 & 2 couldn't be read also in c/ assembly code ?

    You can use timer with SMCLK/1 = MCLK

**Attention** This is a public forum