Code Usage in AVRstudio4.12

Go To Last Post
2 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I have been looking all over for a hint on how to see how often parts of my code are executed. I am using WinAVR compiler and have studied the generated code in disassembler and found that my code only makes up about a third of the entire program. All the rest in uncommented ofcourse and hard for this novice to figgure out what's going on.

My goal is to trim code size. I am doing some unsigned floating point multiplying and dividing, which I assume is making up much of that code from the libraries. I hate to use floats in uC but I don't see any way around it in my app.

Please also see earlyer post "Profiling with AVR studio" by ganyaik

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Well the essence of code profiling is to track how often each funtion is entered. Short of a runtime analysis tool, what you can do is have a global array of ints then assign each funtion in the program an index in the array. At the entry to each function have a profile_array[this_functions_index]++ - at the end of the run have some way to dump the contents of the profile_array[] back to the PC and it'll show the relative frequency with which each function is called (if at all). For lib functions like printf() and strcpy() you'd need to write your own wrapper functions to increment the profile array and then pass the parms onto the libc function.

Course if you are doing FP then even an a=b/c will involve a call to a libc floating point udiv() function and it would be tricky to catch this for profiling in this way.

Cliff