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.

CCS/TM4C129ENCPDT: CPU load rate calculation or determination

Part Number: TM4C129ENCPDT


Tool/software: Code Composer Studio

I developped an application and I would like measure the CPU load rate ?

How I can do this, with CCS (I use ccs v9), with dedicated API, with code in application etc.

Thanks a lot for your response.   

  • Hi,

      I don't think you can measure the CPU load without running an OS. If your application is developed with the TI-RTOS then the TI-RTOS has the instrumentation feature to measure the time the CPU is idle. Without the OS, I don't think it can be done. I'm not aware of any API that does that. 

  • Hi,

    Thank you Charles for your answer. I do not have an OS (as TI RTOS). My application only works under interrupt (uart and ethernet).
    I have a code that measures the number of sequencer cycles per second when I have nothing on the UART and Ethernet (this is my reference). Then, with a loaded application, I measure the difference with my reference to establish a percentage.
    It seems relevant to you ?   

    Best regard

  • Greetings,

    If I may - staff & I are 'betting' that vendor's Charles will 'generally' *LIKE* your method.     We DO - that's for sure - and as many/most of our programs, 'Sit in IDLE'  (i.e. 'eased processing/checking' demands)  until 'Interrupted into Action' - we employ (almost) exactly the same technique!

    There's yet 'another' indirect method to 'monitor' such 'MCU Loading.'     (MCUs - not CPUs lurk here...)   Most always - the MCU's current will increase during the 'more intense, Non-Idle periods'  - which so often occur during, 'Interrupt Handling.'    These current 'peaks' (especially when 'logged per unit time') provide further insight into the MCU's 'actions/whereabouts!'

    The Pro IDE 'IAR' has a 'built-in capability' which - while we've not yet employed it - may also 'Automate' much of  this (valuable), 'Load Monitoring.'    Minus the (real) IDE - resourcefulness (must) be your friend...

  • Hi Mehdi,

      Thanks for sharing your idea. I just wonder how accurate your method is. With that said, I'm sure it will benefit the community if you can share more details. 

      With the RTOS, each task is managed/scheduled by the OS. When no tasks are running, the CPU is running the Idle/default task. So it is quite easy for the OS to instrument on the CPU loading. 

  • Hi Charles,

    Thanks also for the answer.

    My method is very simple. In my code (While (1) of main.c), I integrated a counter and a timer which give me the numbers of cycle done by my main loop per second.
    After to depend of application. In my case I find a reference value that corresponds to the number of cycles when the CPU is not loaded (NbCycleIdleState). Once the value is set I put my target into working condition and I calculate the ratio in percent (((NbCycleIdleState - NbCycleCurrent)/NbCycleIdleState)*100). It may be interesting to voluntarily load the CPU with a compute loop to establish an operating limit for defined the margin.

    Best regards