CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

Microchip ICD2

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Tue Jun 14, 2005 11:26 am     Reply with quote

Quote:
I am not having so much luck with C, I can't even figure out how to watch C variables!

I assume you want to use the ICD2 in debugger mode, and watch
variables as you step through the code. It's really simple.

1. Create a project in MPLAB 7.10. Use the program shown below,
which just increments a variable.

2. In the Debugger menu, go to Select Tool, and choose MPLAB ICD2.

3. Click on the Compile button to compile to program.

4. In the Debugger menu, select Connect. You should see several
messages in the Output window which shows that you connected
OK to the ICD2.

5. Now press the Program button (or select Program in the Debug menu).

At this point, you've programmed the PIC with your program and
with the "Debug Executive" code, which MPLAB puts up near the end
of the ROM memory in your PIC. (This Debug Executive is not
programmed into your PIC when you use the ICD2 in Program mode.)

6. Now go to the View menu and select item 6, Watch. A little
watch window will pop up.

7. In the Watch window, there's a drop-down box at the top right.
It says CCP_1. Scroll down in it and select "my_var". Now
click on the Add Symbol button. "my_var" will now be in the
watch list. Initially it will say "out of scope". Don't worry about
that. The key point is that you have to select the variable AND
click on the Add Symbol button to add it to the Watch list.

8. Arrange the windows on your screen so the Watch window will always
be visible. Maybe shrink the Output window down in size to make
room for the Watch window.

9. Now press the F7 key to step through the code. Eventually the
code in the while() loop will execute and you will see "my_var"
start incrementing each time you press F7.

Here is the test program:
Code:

#include <16f877.h>
#fuses HS, NOWDT, NOPROTECT, PUT, BROWNOUT, NOLVP
#use delay(clock=20000000)

void main()
{
char my_var;

my_var = 0;

while(1)
  {
   my_var++;
  }

}
   
Guest








PostPosted: Tue Jun 14, 2005 4:04 pm     Reply with quote

Thanks for the detailed answer, it turns out that this tip was what I needed :
[quote="PCM programmer"]
Quote:

5. Now press the Program button (or select Program in the Debug menu).

At this point, you've programmed the PIC with your program and
with the "Debug Executive" code, which MPLAB puts up near the end
of the ROM memory in your PIC. (This Debug Executive is not
programmed into your PIC when you use the ICD2 in Program mode.)


Now I am able to watch my variables.

Thanks,

RobM
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group