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

More PIC24 and PCD issues

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



Joined: 24 Jun 2005
Posts: 206

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

More PIC24 and PCD issues
PostPosted: Wed Nov 28, 2012 7:03 pm     Reply with quote

Hi All,

Still trying to port some code to a PIC24 using CCS 4.124. I can't believe it is so hard.

Anyway, I have an Ethernet application working in PIC18. All I have changed in the stack is what timer the tick function uses and what pins are used to connect to the ENC28J60. Nothing else has changed. Now when I try to compile, I get the following error:
Code:

arptsk.c Line 130(1,1): Function used but not defined:  ... ARPGet  SCR=32031


I am just using the CCS stack so I will not post all of of arptsk.c, But at the top of it we have:
Code:

#include "tcpip/arp.h"


In arp.h we have:
Code:

BOOL    ARPGet(NODE_INFO *remote, BYTE *opCode);

So the question is, why is the compiler complaining about this. The code works fine with PCH so I don't think there is any issues with the code. Looks more like a compiler issue?

Thanks
asmallri



Joined: 12 Aug 2004
Posts: 1635
Location: Perth, Australia

View user's profile Send private message Send e-mail Visit poster's website

PostPosted: Wed Nov 28, 2012 9:51 pm     Reply with quote

It may be a case sensitive issue.

Checkout #case
_________________
Regards, Andrew

http://www.brushelectronics.com/software
Home of Ethernet, SD card and Encrypted Serial Bootloaders for PICs!!
Markdem



Joined: 24 Jun 2005
Posts: 206

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

PostPosted: Thu Nov 29, 2012 12:07 am     Reply with quote

Hi Asmallri,

Tried with #case just in case (no pun intended) but that did not help.

I have now changed the code back to PIC18 by only changing the device line at the top of main and changing the device in MPLAB. I have left the timer and pin defines configured for the PIC24 just in case that was the issue somehow and it complies fine. I just looks like PCD is doing something silly.

What else can i try to fix the issue? does the SCR=32031 at the end of the error message mean anything useful?

Thanks
FvM



Joined: 27 Aug 2008
Posts: 2337
Location: Germany

View user's profile Send private message

PostPosted: Thu Nov 29, 2012 8:01 am     Reply with quote

Quote:
In arp.h we have:

BOOL ARPGet(NODE_INFO *remote, BYTE *opCode);

So the question is, why is the compiler complaining about this. The code works fine with PCH so I don't think there is any issues with the code. Looks more like a compiler issue?


In arp.h, you have a function prototype, but obviously you don't have a function definition. Nothing you should PCD blame for. It may a matter of processor specific conditionals in the TCP/IP code, or just missing sources.

Please notice the difference between these error messages:
Function used but not defined and
Undefined identifier
Markdem



Joined: 24 Jun 2005
Posts: 206

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

PostPosted: Thu Nov 29, 2012 4:44 pm     Reply with quote

Hi FvM,

The function is defined in arp.c with gets included from stacktsk.c.

Like I said, this project works fine when complied with PCH:
Code:
Executing: "C:\Program Files (x86)\PICC\4124\Ccsc.exe" +FH "main.c" #__DEBUG=1 +ICD +DF +LN +T +A +M +Z +Y=9 +EA  #__18F4620=TRUE
>>> Warning 201 "C:\Users\mdemczuk.CAE.CA\Desktop\Web Server - PIC18\Firmware\tcpip\helpers.c" Line 189(1,1): Assignment inside relational expression
>>> Warning 203 "C:\Users\mdemczuk.CAE.CA\Desktop\Web Server - PIC18\Firmware\mpfs\mpfs.c" Line 185(1,1): Condition always TRUE
>>> Warning 203 "main.c" Line 37(1,1): Condition always TRUE
      Memory usage:   ROM=31%      RAM=12% - 16%
      0 Errors,  3 Warnings.
Loaded C:\Users\mdemczuk.CAE.CA\Desktop\Web Server - PIC18\Firmware\main.cof.
BUILD SUCCEEDED: Fri Nov 30 09:35:32 2012


But fails with PCD:
Code:

Executing: "C:\Program Files (x86)\PICC\4124\Ccsc.exe" +FD "main.c" #__DEBUG=1 +ICD +DF +LN +T +A +M +Z +Y=9 +EA  #__PIC24FJ256DA210__=TRUE
>>> Warning 201 "C:\Users\mdemczuk.CAE.CA\Desktop\Web Server - PIC18\Firmware\tcpip\helpers.c" Line 189(1,1): Assignment inside relational expression
>>> Warning 203 "C:\Users\mdemczuk.CAE.CA\Desktop\Web Server - PIC18\Firmware\mpfs\mpfs.c" Line 185(1,1): Condition always TRUE
>>> Warning 203 "main.c" Line 37(1,1): Condition always TRUE
*** Error 112 "C:\Users\mdemczuk.CAE.CA\Desktop\Web Server - PIC18\Firmware\tcpip\arptsk.c" Line 130(1,1): Function used but not defined:  ... ARPGet  SCR=33991
      1 Errors,  3 Warnings.
Halting build on first failure as requested.
BUILD FAILED: Fri Nov 30 09:31:28 2012


The only thing I changed is the following two lines and the device selection in MPLAB:
Code:

//#include <24FJ256DA210.h>
#include <18F4620.h>

No fuse setting, timers, pins or anything else gets changed. (I know the code will not run without changes to fuse settings but this is just to test).

This is driving me crazy. Is there anything else I can try short of upgrading my compiler version (its not that old)?

Thanks
Markdem



Joined: 24 Jun 2005
Posts: 206

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

PostPosted: Thu Nov 29, 2012 5:31 pm     Reply with quote

I am going to lose it today.

I changed the function name from ARPGet to STUPID and guess what, it now works!

Code:

Executing: "C:\Program Files (x86)\PICC\4124\Ccsc.exe" +FD "..\..\..\..\Desktop\Web Server - PIC18\Firmware\main.c" #__DEBUG=1 +ICD +DF +LN +T +A +M +Z +Y=9 +EA  #__PIC24FJ256DA210__=TRUE
>>> Warning 201 "C:\Users\mdemczuk.CAE.CA\Desktop\Web Server - PIC18\Firmware\tcpip\helpers.c" Line 189(1,1): Assignment inside relational expression
>>> Warning 203 "C:\Users\mdemczuk.CAE.CA\Desktop\Web Server - PIC18\Firmware\mpfs\mpfs.c" Line 185(1,1): Condition always TRUE
>>> Warning 203 "main.c" Line 37(1,1): Condition always TRUE
      Memory usage:   ROM=7%      RAM=2% - 3%
      0 Errors,  3 Warnings.
Loaded C:\Users\mdemczuk.CAE.CA\Desktop\Web Server - PIC18\Firmware\main.cof.
BUILD SUCCEEDED: Fri Nov 30 10:11:42 2012


I then commented out the prototype in arp.h, renamed the function to ARPGet again and now it compiles (I have not tested it it works yet).

Question is, why is the prototype making PCD fail when PCH works fine?
Second question is, what is the point of that prototype? I have checked and ARPGet is only used once in the whole project.

Lets see if it still works in hardware without the prototype. My guess is it will.
Thanks again.
Ttelmah



Joined: 11 Mar 2010
Posts: 19559

View user's profile Send private message

PostPosted: Fri Nov 30, 2012 2:10 am     Reply with quote

OK.
Prototypes have nothing to do with how often a function is used.
They have two separate 'functions'.

The first is to allow the actual definitions to be elsewhere (another module, or further down the code), so that the compiler knows what to 'expect'. In C, all things must be declared before they are used, and having a prototype allows you to make sure this is the case. Original 'C', did not have 'prototypes' as such, requiring the declaration, but not requiring the variable types etc. to be shown.
This is their only real function in CCS.

The other part of their function, is as compilers have got more sophisticated, and support things like overloading, having the variable types declared in the prototype allows checking that types do match. CCS checks that the declarations in the prototype 'match' those in the actual definition (more strictly than is really required), but then does no checking about what is actually passed/used. This is down to the language, rather than CCS, with C, not being an explicitly 'typed' language, so it is perfectly legitimate to pass (say) an int to a function expecting a 'float', while on most more complex languages this has to be explicitly handled.

My guess would be that there is a tiny typing error somewhere in the PCD prototype declaration. Possibly even a 'hidden' character, or a difference in the variable declarations from the real function (the easiest way to get prototypes 'right' is to cut and paste the first line from the declaration, and just add the ';' in place of the '{'). Possibly the most likely thing, is related to the difference in size of a default integer in PCD (signed int16), with something using 'int' in one place and explicit sizing elsewhere....

Best Wishes
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