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

CCS compiler & MPLAB X ->data types mixing

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



Joined: 19 Dec 2014
Posts: 7

View user's profile Send private message

CCS compiler & MPLAB X ->data types mixing
PostPosted: Mon Jan 12, 2015 12:38 am     Reply with quote

Hi,

Stuck with a project, using CCS compiler 5.015 with MPLAB X 2.26
This combination is forced itself since trying to debug PIC 24FJ128GB206, couldn't manage to work with ICD-U40 ( v5 ! ) and also pickit3 with CCS IDE. So trying to solve this bottle neck with CCS + MPLAB + pickit3.

Because of the data types defined in CCS before , (actually they were fine under CCS IDE ) , some strange behavior started under MPLAB IDE;
- "If" is not working like
Code:
 if (var1>1023) ...
var1 is defined as int16
- type conversions is not working
Code:
var1 = (int)var2
var1 defined int

When I try to change the variable definitions as;

int -> unsigned char
int16 -> unsigned int

still have problems which mixes everything.

Can anyone please guide me on this, read both compilers data types but couldn't figure it out ! As far as I understand MPLAB intervene to the compile process, so my old code working under CCS IDE is not fine anymore.

Maybe I am missing a CCS compiler directive, working under MPLAB ?

Thanks.
Ttelmah



Joined: 11 Mar 2010
Posts: 19535

View user's profile Send private message

PostPosted: Mon Jan 12, 2015 1:45 am     Reply with quote

An int is not a char.

On the DsPIC's, an int, defaults to an int16.

If you change your int definition to char, then 'of course' a comparison with 1023 is not going to work (char == int8).

Try using MPLAB, rather than MPLAB-X. MPLAB-X, is 'unfortunate', I have had to use it, but have yet to see a release that actually fully works. It actually makes CCS's 'bugs' look minor. MPLAB 8.92, is currently the 'best' debugger around, provided your chip is supported (yours is).

Yes, MPLAB _will_ interfere with the compile process _if you have debug mode selected_. It won't otherwise, but then you can't debug. It defaults to debug mode.

With the some compilers, the comment in the CCS 'readme', is wrong. They say that integers default to unsigned, but in fact on some versions the default is signed. This gives some oddities like you are experiencing, with (for instance), an 'int' that increments past 32767, automatically being treated as a -ve number. This may be your core problem.
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