Tracking microcontroller clock cycles while simulating my code on a microcontroller

Thread Starter

Tanushree Banerjee

Joined Dec 9, 2015
I've recently started using Proteus 8 Professional .
I have a quick question for which I did't find precise answer in the documentations.
I have written some basic code in Atmel Studio 7, uploaded its hex file on Atmega 328 and simulated that in Proteus 8 Professional.

Now I'm interested to find how many processor cycles are used by this particular microcontroller(Atmega 328) to run my code.
(I could just see the timer saying "ANIMATING", increasing at the lower left end of the screen), is there some other place to properly measure it?
(That is can I measure/track the processor cycles used while simulating my code on the selected microcontroller ?)


Joined Jun 26, 2012
I'm not familiar with either AS7 or Proteus but what you are looking for is a 'Stop Watch' function that runs under the debugger and counts cycles between breakpoints. Page 55 of the Atmel Studio 7 manual shows the stopwatch. From working with others here using Proteus, I'm pretty sure it has a code-debug function that allows breakpoints and cycle analysis. Worst case, load your output file into Studio 7 and simulate it there.

A usable technique is to dedicate an output line to debugging. Set it when entering a routine, clear it on exit then use Proteus' scope function to measure the time and convert that to cycles. Not perfect but not bad either.

The term to describe what you want is PROFILING the code. Search around on 'profiling' too.

Sorry I don't have more specifics but poke around along those lines.

Good luck and welcome to AAC!