Friday, 15 February 2013

c++ - calculating code runtime in highly optimized code -



c++ - calculating code runtime in highly optimized code -

i'm working on cortex m3 , using iar ewarm. utilize dwt_dyccnt timing calculation. problem when optimize code speed (using compiler options), lose value of dwt_dyccnt while debugging. code in c , c++. tried printing value of variable using printf returns errors.

i tried making variable volatile, doesnt help.

while debugging unknown value variable.

i want know how calculate timing of code in code has been optimized speed , not lose value of variables. how can forcefulness compiler retain value of these variables?

edit:

volatile int count = 0; volatile unsigned int *dwt_cyccnt = (unsigned int *)0xe0001004; //address of register volatile unsigned int *dwt_control = (unsigned int *)0xe0001000; //address of register volatile unsigned int *scb_demcr = (unsigned int *)0xe000edfc; //address of register *scb_demcr = *scb_demcr | 0x01000000; *dwt_cyccnt = 0; // reset counter *dwt_control = *dwt_control | 1 ; // enable counter _do_something_here_ count = *dwt_cyccnt; printf("\n count!!!! = %d",*dwt_cyccnt);

the value of count "lost" when debugging code.

thanks

if want measure period of time, utilize oscilloscope. set pin high when entering code section timing want measure , set pin low when section ends.

this accurate way measure timings in embedded.

c++ optimization iar

No comments:

Post a Comment