I want to look at some registers using the variable 'debug'. However, the variable does not appear in the Locals window.
Reading other posts, they say I need to use the variable otherwise the compiler has 'optimises it out'. Very cute...
However, I have declared it and used it and still it does not appear in the locals window. Not so cute...
here is how I am declaring and using it:
unsigned int n; unsigned int debug; unsigned int junk; volatile AT91PS_PIO pPIOA = AT91C_BASE_PIOA; /* pointer to Parallel I/O */ volatile AT91PS_RTTC pRTTC = AT91C_BASE_RTTC; /* pointer to RTTC */ volatile AT91PS_TC pTC = AT91C_BASE_TC0; /* use TC0 only*/ initialise_PIOA(); intialise_TC0(); debug = 1; debug = debug + 1;
I have also tried declaring it as volatile with no success.
What am I doing wrong....?
Please let me know
Thanks
As it's local, perhaps the compiler might still be able to detect that it does nothing, and optimise it out?
Have you checked the disassembly to see if any code is actually being generated for it?
Where are you using your variable? debug = debug+1 isn't the same as using, if you don't have any code somewhere else that actually cares.
Have you tried changing debug into a global variable?
Wow - you guys are quick to answer...
Later in my code I have:
debug = pTC->TC_SR;
I appreciate I can view the TC_SR reg using other methods, but I want to set up a general debug methodology.
Does this line constitute me using the variable?
I will try making it global and see how far that gets me...
This is using:
if (debug > 1) do_stuff();
To use a variable, some part of the code should read the contents, and be affected by different contents.
Perhaps if you explained what you're actually trying to achieve here, people might be able to offer suggestions?
I get the impression that we're currently just fiddling with a fundamentally broken approach...?
I was single stepping through my code and i wanted to look at the code window and the Locals window and check the flags in the Timer Counter status register. The size of the Timer Counter Register window cannot be changed and covers up the code I am trying to examine. A simple variable reading the TC_SR register would solve this problem. I then got into the loop of:
This is so trivial, it should be easy to do -> I cannot figure out how to do it -> what am I doing wrong? -> This is so trivial....
repeat ad nausium..
Perhaps you should take a look at uVision's Debug Functions facility:
http://www.keil.com/support/man/docs/uv3/uv3_debug_functions.htm
and maybe getter a bigger screen and/or a second screen...
A simple variable reading the TC_SR register would solve this problem.
Then you'll have to qualifay that variable as "volatile". That's how you tell the compiler you want every access to that variable to take place exactly as it's spelled out in the source --- no optimizations, no reuse of the variable's space for other temporary values, nothing.