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 CCS Technical Support

How to debug PCM compiled code in MPLAB with ICD2

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



Joined: 25 Jan 2008
Posts: 4
Location: Stuttgart / Germany

View user's profile Send private message

How to debug PCM compiled code in MPLAB with ICD2
PostPosted: Wed Jan 30, 2008 9:59 am     Reply with quote

Hi all,

I'm a CCS newbie. I've tried to debug a c-project (multiple c-files) in MPLAB 8.0 with ICD2. But i can only step inside the disassembler window. Not inside the C-source window. I would like to do debugging in the c-code. Is it possible ? Any hints on how-to ? Which Debug-File format ?

Thx.
Many Regards, Thomas
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Thu Jan 31, 2008 3:00 pm     Reply with quote

I tested this just now with MPLAB vs. 8.01 and PCM vs. 4.066. It worked
fine.

1. Install the MPLAB, the CCS compiler, and the CCS plug-in.
2. Create a new project in MPLAB, using the Project Wizard.
3. Connect the ICD2 between your PC and your test board.
4. In MPLAB, in the Debugger menu, goto Select Tool, and choose ICD2.
5. Then compile your program.
6. Go to the Debugger menu, and select Connect. It may announce
that it's downloading a new "operating system" to the ICD2. Wait
for it to finish.
7. In the Debugger menu, select Program. Wait for the ICD2 to finish
programming the PIC.

8. Let's assume you have the following program as your project.
You should have this program visible in the source window.
Code:
#include <16F877.H>
#fuses XT, NOWDT, PUT, BROWNOUT, NOLVP
#use delay(clock=4000000)

//=========================
void main()
{
int8 c;

c = 1;
c = 2;
c = 3;
c = 4;

while(1);
}

Go to the line for "c = 1;", and double-click in the margin to the left
of that line. A red circle with a "B" should appear. If you get a hollow
circle without the B, then it means you didn't do one of the steps above,
such as programming the PIC from with the Debugger menu.

9. Now press the F9 key. The program should run to the line with the
breakpoint on it and stop. A little green arrow in the margin should be
pointing to that line.

10. Now press the F8 key, slowly, once per second. After each press,
the little green arrow should advance to the next line. This is all taking
place in the source code window. All this time, you will be looking at the
program posted above.

It works fine for me.
wollibk



Joined: 25 Jan 2008
Posts: 4
Location: Stuttgart / Germany

View user's profile Send private message

PostPosted: Fri Feb 01, 2008 4:27 am     Reply with quote

Thanks PCM.

This describes is how i've done/tried it. But this doesn't work if your source consists of many c-files (like main.c adc.c i2c.c timer.c blabla.c). Then only the first linked file will be opened and you'll step always in this c-file even when the source is in another file. In other words: multi c-source debugging doesn't work in MPLAB8.0 w/ CCS-Compiler.
Any hints ?

thx.
eyewonder300



Joined: 09 Jun 2004
Posts: 52

View user's profile Send private message

Multiple source files
PostPosted: Sat Feb 02, 2008 9:33 am     Reply with quote

I can't remember why I did it this way, but on some projects I made one *.c file that had my 'main()', and several separate files with related groups of functions/procedures. I named them as *.h files, added them under header file section of the project , and that worked for me. You might give that a try.

Cheers
Steve
ckielstra



Joined: 18 Mar 2004
Posts: 3680
Location: The Netherlands

View user's profile Send private message

PostPosted: Sat Feb 02, 2008 12:52 pm     Reply with quote

I never had problems debugging multiple C-files in my projects. What is the version number of your CCS compiler?
mkuang



Joined: 14 Dec 2007
Posts: 257

View user's profile Send private message Send e-mail

PostPosted: Tue Jun 23, 2009 8:42 am     Reply with quote

PCM programmer wrote:
I tested this just now with MPLAB vs. 8.01 and PCM vs. 4.066. It worked
fine.

1. Install the MPLAB, the CCS compiler, and the CCS plug-in.
2. Create a new project in MPLAB, using the Project Wizard.
3. Connect the ICD2 between your PC and your test board.
4. In MPLAB, in the Debugger menu, goto Select Tool, and choose ICD2.
5. Then compile your program.
6. Go to the Debugger menu, and select Connect. It may announce
that it's downloading a new "operating system" to the ICD2. Wait
for it to finish.
7. In the Debugger menu, select Program. Wait for the ICD2 to finish
programming the PIC.

8. Let's assume you have the following program as your project.
You should have this program visible in the source window.
Code:
#include <16F877.H>
#fuses XT, NOWDT, PUT, BROWNOUT, NOLVP
#use delay(clock=4000000)

//=========================
void main()
{
int8 c;

c = 1;
c = 2;
c = 3;
c = 4;

while(1);
}

Go to the line for "c = 1;", and double-click in the margin to the left
of that line. A red circle with a "B" should appear. If you get a hollow
circle without the B, then it means you didn't do one of the steps above,
such as programming the PIC from with the Debugger menu.

9. Now press the F9 key. The program should run to the line with the
breakpoint on it and stop. A little green arrow in the margin should be
pointing to that line.

10. Now press the F8 key, slowly, once per second. After each press,
the little green arrow should advance to the next line. This is all taking
place in the source code window. All this time, you will be looking at the
program posted above.

It works fine for me.

Hello,

I tried the test program except I replaced the <16f877> with <18f2525> and after I program the chip and hit connect I get this:

Programming Target...
...Validating configuration fields
...Erasing Part
...Programming Program Memory (0x0 - 0x3F)
...Loading DebugExecutive
...Programming DebugExecutive
...Programming Debug Vector
...Programming RSBUG
Verifying...
...Program Memory
...Debug Executive
...Debug Vector
...Verify Succeeded
Programming Configuration Bits
.. Config Memory
Verifying configuration memory...
...Verify Succeeded
Connecting to debug executive
ICD0083: Debug: Unable to enter debug mode. Please double click this message for more information.
MPLAB ICD 2 Ready


I have always used the ICD2 hockey puck as a programmer and haven't tried it as a debugger. It is connected to the PIC via a 5 pin connector where the pins are PIN1 to GND, PIN2 to Vcc (5V), PIN3 to MCLR (which has a 10K pullup tp 5V), PIN4 to PGMD and PIN5 to PGMC.
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Tue Jun 23, 2009 11:14 am     Reply with quote

Look for the answer in the Microchip ICD forum archives:
http://www.microchip.com/forums/search.aspx
Use this for the Search Term:
Quote:
ICD0083

On the right side, select this forum:
Quote:
- - MPLAB ICD In Circuit Debuggers

Then click OK and you will get hundreds of posts on this topic.
mkuang



Joined: 14 Dec 2007
Posts: 257

View user's profile Send private message Send e-mail

PostPosted: Tue Jun 23, 2009 11:52 am     Reply with quote

Hi,

It worked...after I unplugged the hockey puck from the computer a few times. Thanks.
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