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

MPLAB ICD2 multi file project debug problem
Goto page 1, 2  Next
 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
seb



Joined: 18 Mar 2009
Posts: 3

View user's profile Send private message

MPLAB ICD2 multi file project debug problem
PostPosted: Wed Mar 18, 2009 8:44 am     Reply with quote

Hi,

I'm using MPLAB 8.20 CCS compiler v4.075 and ICD2. The device is a PIC16F876. I'm trying to debug a project with multiple files. However if I set a breakpoint in a file other than the file containing main() it is never reached. I also can not step from one file into the next. If one file contains a function call to a function in another file I would expect the debugger to jump into the next file (as it does when using C30 compiler or SourceBoost compiler). However this does not seem to work.

The following link contains a small multi file MPLAB project to reproduce the error. http://78.46.66.194/~cherry/delme/bug.zip
Not sure if there is a bug in the compiler (invalid COF file?) or if I am doing something wrong or or I misconfigured something.

I would be glad if somebody could have a look, try to reproduce the problem or give me a heads up on what I'm doing wrong.

Thanks in advance,
seb
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Wed Mar 18, 2009 11:38 am     Reply with quote

I tried your project and it didn't compile. I created a "bug" directory
within the CCS directory structure. Then I copied your files to it.
I installed pcm vs. 4.076. I clicked on your "Bug" project icon to
launch the project. I clicked the compile button. It gives an error.
It says:
Quote:
Function used but not defined: Test

Did you test this before posting ?

See this post on how to arrange your main source file in a multi-file
project in MPLAB with CCS:
http://www.ccsinfo.com/forum/viewtopic.php?t=18649&start=1
It's all one big file. This is not like MSVC. Don't include the
16F876.h file in all files. It only goes at the top of the main source file.

When you first create your project, the Project window it should look like
this:
Code:

-Bug.mcp
  - Source Files
     - display.c
  -Header Files
  -Other Files
 

Only the display.c file (the main file) is added to the project.
MPLAB will take care of adding any header files to the project window,
as it reads them, during compilation. You can manually add your other
C source files to the "Other Files" list by right-clicking on it. This is just
done to make it easy to access them. It doesn't affect how MPLAB
compiles the project.
seb



Joined: 18 Mar 2009
Posts: 3

View user's profile Send private message

PostPosted: Thu Mar 19, 2009 2:58 am     Reply with quote

PCM programmer,

thank you very much for taking the time and lookin at my problem. Unfortunately you are right - it does not compile. I tested it (it did compile) and then renamed the .mcp file to bug.mcp which causes the linking step to fail. I uploaded a new archive with the correct file and this time it does compile and link on my system (I checked 3 times) http://78.46.66.194/~cherry/delme/bug2.zip

Quote:
Executing: "C:\Program files\Picc\CCSC.exe" +FM "display.c" +EXPORT +DF +LS +T +A +M -Z +ICD +Y=0 +EA
>>> Warning 203 "display.c" Line 18(1,1): Condition always TRUE
C:\Users\asdf\Desktop\bug\display.o ===> 0 Errors, 1 Warnings.
Executing: "C:\Program files\Picc\CCSC.exe" +FM "test.c" +EXPORT +DF +LS +T +A +M -Z +ICD +Y=0 +EA
C:\Users\asdf\Desktop\bug\test.o ===> 0 Errors, 0 Warnings.
Executing: "C:\Program files\Picc\CCSC.exe" +FM LINK="IZAR Display.hex=display.o,test.o" +DF +LS +T +A +M -Z +ICD +Y=0 +EA
Memory usage: ROM=0% RAM=2% - 2%
0 Errors, 0 Warnings.
Loaded C:\Users\asdf\Desktop\bug\IZAR Display.cof.
BUILD SUCCEEDED: Thu Mar 19 09:39:24 2009


With this you should be able to reproduce the problem. And as you can see there seems to be a linking stage there..
But from what your saying I understand that what I'm trying to do is not possible? To be honest this is quite a disappointment.

edit: as an additional comment I now tried the procedure you recommended and this does indeed work. So thanks again! However I might add that this is very unusual compared to other compilers I worked with before.

seb
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Thu Mar 19, 2009 11:43 am     Reply with quote

I can't make your new code compile.
You said that my recommended procedure works. Does this mean that
your original problem with debugging is also solved ?
seb



Joined: 18 Mar 2009
Posts: 3

View user's profile Send private message

PostPosted: Mon Mar 30, 2009 1:40 am     Reply with quote

Curious, why can I compile the code and you can not?
My original problem is not really solved but your workaround works. I'm kind of surprised that such an expensive compiler suite does not support linking.
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Mon Mar 30, 2009 1:26 pm     Reply with quote

Quote:
I'm kind of surprised that such an expensive compiler suite does not support linking.

It does, but only if you have the CCS IDE. CCS wants to sell you the
IDE, so they make it so certain things only work with the IDE, such as
linkable modules, generation of the statistics file (.STA), etc.
http://www.ccsinfo.com/content.php?page=ideoverview#multiple

But the low cost route is to use the command line compiler(s) with MPLAB.
That's what I do. I don't need the linkable modules feature.
juanjose



Joined: 08 May 2008
Posts: 9

View user's profile Send private message

PostPosted: Thu Apr 09, 2009 8:58 pm     Reply with quote

The original question is still not solved on my case, as follows.
"However if I set a breakpoint in a file other than the file containing main() it is never reached"

You cant take the simplest program
using ccs 4.083 and MPLab 8.02 and SIMULATOR AS DEBUGGER
Code:
// file "tbreak.c"
#include "tbreak.h"
int get_int();
main()
{
int a = 0;
a= get_int();
return a;
}

Code:

// file "sub_rot.c"
#include "tbreak.h"
int get_int()
{
return 5;
}


Code:
//file "tbreak.h"
#include <18F4450.h>

Breakpoints on the file "tbreak.c" works all right.
But when you try to put a breakpoint on the statement "return 5;" of file "sub_rot.c"
you get a yellow question mark on the BREAKPOINTS window.
And if you try to start simulator you get following message
"one or more breakpoints could not be resolved. ............................."

Some people say is because there is no link, but that do not make sense to me, as the programs are so much linked that the two sources do work together. The only problem is when setting the breakpoint setting, or try to step into the other source.
juanjose



Joined: 08 May 2008
Posts: 9

View user's profile Send private message

PostPosted: Thu Apr 09, 2009 9:28 pm     Reply with quote

Forgot to mention that I have selected on the project options
Project --> Build options -->project -->CCS C compiler DEBUG COFF format
thanks again
juan
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Thu Apr 09, 2009 11:23 pm     Reply with quote

Your code does not show an #include line for this file: "sub_rot.c"
So I don't know how you can compile it with CCS in MPLAB.
juanjose



Joined: 08 May 2008
Posts: 9

View user's profile Send private message

PostPosted: Fri Apr 10, 2009 10:20 am     Reply with quote

hi PCM, thanks for your answer

I include file: "sub_rot.c" into the MPLAB Project Tree.
I imagine this tree informs the MPLAB Make all segments that must be compiled.
It works alright

Pls see following compilation screen output :
Clean: Done.
Executing: "D:\Program Files\PICC\Ccsc.exe" +FH "tbreak.c" +EXPORT +DF +LN +T +A +M +Z +Y=9 +EA
Z:\ccs_test\Tbreak\tbreak.o ===> 0 Errors, 0 Warnings.
Executing: "D:\Program Files\PICC\Ccsc.exe" +FH "sub_rot.c" +EXPORT +DF +LN +T +A +M +Z +Y=9 +EA
Z:\ccs_test\Tbreak\sub_rot.o ===> 0 Errors, 0 Warnings.
Executing: "D:\Program Files\PICC\Ccsc.exe" +FH LINK="tbreak.hex=tbreak.o,sub_rot.o" +DF +LN +T +A +M +Z +Y=9 +EA
Memory usage: ROM=0% RAM=1% - 1%
0 Errors, 0 Warnings.
Loaded Z:\ccs_test\Tbreak\tbreak.cof.
BUILD SUCCEEDED: Fri Apr 10 13:07:06 2009
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Fri Apr 10, 2009 10:54 am     Reply with quote

I can't make your method work. I created the 3 files as shown in
your post. Then, as you said, I added the 2 main files to the MPLAB
project. The project window looks like this:
Code:
- Test.mcp
-- Source Files
---- sub_rot.c
---- tbreak.c
-- Header Files
---- 18F4550.h
---- tbreak.h
-- Object Files
-- Other Files
---- sub_rot.sym
---- tbreak.sym


When I click on the "Compile" button in MPLAB, I get this error:
Quote:
*** Error 112 "tbreak.c" Line 7(1,1): Function used but not defined: ... get_int SCR=323


Please explain how you compile these files without getting that error.
My test was done with PCH compiler vs. 4.090 and MPLAB vs. 8.20a.
juanjose



Joined: 08 May 2008
Posts: 9

View user's profile Send private message

PostPosted: Fri Apr 10, 2009 12:07 pm     Reply with quote

I appreciate very much you help

My version compiles ok, as I show you on the output screen at the end of this note.
I am using MPLAB 8.3, CCS version 4.083

My project windows looks as follows ( is a little different from yours just on the other files).


- Test.mcp
-- Source Files
---- sub_rot.c
---- tbreak.c
-- Header Files
---- 18F4550.h
---- tbreak.h
-- Object Files
-- Other Files
---- sub_rot.OSYM
---- tbreak.OSYM
-----tbreak.STA
-----tbreak.SYM
-----tbreak.TRE

Just in case I am attaching again the files content
Code:
---------------------------------------------------
//   tbreak.c   FILE
#include "tbreak.h"

int get_int();

main()
{
int a = 0;
a= get_int();
return a;
}
--------------------------------
// sub_rot.c   FILE
#include "tbreak.h"


int get_int()
{
return 5;
}
-----------------------------
//tbreak.h  FILE

#include <18F4450.h>
----------------------------

my compilation message results are as follows :
Clean: Done.
Executing: "D:\Program Files\PICC\Ccsc.exe" +FH "tbreak.c" +EXPORT +DF +LN +T +A +M +Z +Y=9 +EA
Z:\ccs_test\Tbreak\tbreak.o ===> 0 Errors, 0 Warnings.
Executing: "D:\Program Files\PICC\Ccsc.exe" +FH "sub_rot.c" +EXPORT +DF +LN +T +A +M +Z +Y=9 +EA
Z:\ccs_test\Tbreak\sub_rot.o ===> 0 Errors, 0 Warnings.
Executing: "D:\Program Files\PICC\Ccsc.exe" +FH LINK="tbreak.hex=tbreak.o,sub_rot.o" +DF +LN +T +A +M +Z +Y=9 +EA
Memory usage: ROM=0% RAM=1% - 1%
0 Errors, 0 Warnings.
Loaded Z:\ccs_test\Tbreak\tbreak.cof.
BUILD SUCCEEDED: Fri Apr 10 14:53:44 2009

again, thanks a lot

juan
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Fri Apr 10, 2009 12:24 pm     Reply with quote

Is your CCS compiler the "Full IDE" compiler, such as PCWH ?

Or is it the "command line" compiler, such as PCH ?
juanjose



Joined: 08 May 2008
Posts: 9

View user's profile Send private message

PostPosted: Fri Apr 10, 2009 12:27 pm     Reply with quote

is a full IDE
thanks
juanjose



Joined: 08 May 2008
Posts: 9

View user's profile Send private message

PostPosted: Fri Apr 10, 2009 12:36 pm     Reply with quote

In addition to previous answer,
is a full IDE but the MPLAB use it as a command line compiler, as you can see on the output screen display at the end of my note.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Goto page 1, 2  Next
Page 1 of 2

 
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