different runtime duration for LPC1313

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

different runtime duration for LPC1313

1,046 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by orhan.dirik on Tue Nov 13 02:02:38 MST 2012
We are using LPC1313FBD48 as the control MCU in our new medical design. For  some safety reason we would like to measure the runtime duration of  deterministic code piece. In the attached archive, at main.c a loop runs for  150000 times and a timer is used for measuring this duration.
The problem is  we get different timer counts when changing the code BEFORE the timer starts.  For example, when we use SysInit() function in main.c the timer counts 318753  each time we run the code. However, when we comment out the function and  uncomment the part above it, the timer counts 312503. Please note that, the code  piece above SysInit is the same as SysInit function itself. All in all, timer  counts differ due to previous codes that do not even start the timer.
Can can  we get rid of this problem?
0 Kudos
Reply
4 Replies

1,038 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by orhan.dirik on Tue Nov 13 07:59:09 MST 2012
Thank you very much for your explanations :)
0 Kudos
Reply

1,038 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Ex-Zero on Tue Nov 13 07:52:29 MST 2012

Quote: orhan.dirik
Any comments?



#1 This is a Keil project, so believe it or not I'm talking about LPCXpresso (in LPCXpresso Forum) ;)

#2 It's difficult to determinate what a compiler is doing and how it's working in detail. Different compilers behave different. Especially usage of 'volatile' is different.

#3 Delay functions with loops should of course be replaced by timer functions :)
0 Kudos
Reply

1,038 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by orhan.dirik on Tue Nov 13 07:32:39 MST 2012
Making the variables did not work. However the problem is solved for different optimization levels other than level-0, thank you.
On the other hand, it is little bit confusing now, since level-0 means no optimization I would not expects such a behavior. Having full control over the firmware was my motivation by selecting level-0, but it seems that turning of all optimizations does not provide the control I expected. I also attached the whole project. Any comments?
0 Kudos
Reply

1,038 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Ex-Zero on Tue Nov 13 05:37:32 MST 2012
Don't know which version and which optimization your project is running (you didn't post your complete project ;)),
but i would strongly suggest to tell your compiler how to handle 'dummy'.

Changing your code to
volatile unsigned int counter, result, dummy;
might give you a more stable result through different optimization settings :):)
0 Kudos
Reply