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

PIC24FV32KA304

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



Joined: 30 Jan 2010
Posts: 8

View user's profile Send private message

PIC24FV32KA304
PostPosted: Mon Jan 20, 2014 4:46 pm     Reply with quote

Hello,

i do have a other point switching from a PIC 18 to a PIC24. I know that the PIC24 is 16bit and the PIC18 is 8 bit. But i would have expected that a int8 is still read as a 8bit variable but it seems not. Is this correct?

I just wrote a simple dummy:
Code:

int8 response;

printf("response = 170;\n\r");
      response = 170;
      if (response == 170)
         printf("170 OK\n\r");
      if (response == 0xAA)
         printf("AA OK\n\r");
      if (response == 0xFFAA)
         printf("FFAA OK\n\r");
      if (response == -86)
         printf("-86 OK\n\r");
      printf("response = 0xAA;\n\r");
      response = 0xAA;
      if (response == 170)
         printf("170 OK\n\r");
      if (response == 0xAA)
         printf("AA OK\n\r");
      if (response == 0xFFAA)
         printf("FFAA OK\n\r");
      if (response == -86)
         printf("-86 OK\n\r");

and the result is:

response = 170;
FFAA OK
-86 OK
response = 0xAA;
FFAA OK
-86 OK
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Mon Jan 20, 2014 5:08 pm     Reply with quote

The PCD and PCM/PCH manuals for June 2012 say:

PCD:
Quote:
Note: All types, except char, by default are signed; however, [they] may be preceded by unsigned or signed (Except int64 may only be signed).


PCM/PCH:
Quote:
unsigned - Data is always positive. This is the default data type if not specified
DerWolf



Joined: 30 Jan 2010
Posts: 8

View user's profile Send private message

PostPosted: Mon Jan 20, 2014 5:39 pm     Reply with quote

but if i change the declaration of response to short it is reacting in the same way even it is now defined as unsigned.

regards
A. Wolf
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Mon Jan 20, 2014 5:54 pm     Reply with quote

I don't have the PCD compiler, so I can't run any tests.

There is a problem. CCS changed the latest PCD manual. They appear
to have copied and pasted the "Basic and Special Types" section from
the PCW (PCM/PCH) manual into the PCD manual.

For example, in both of the current Nov. 2013 manuals, CCS
claims that a 'short' is an 'int1'.

But in the June 2012 manuals, the PCD version says a 'short' is an 'int8'.
The PCW manual says it's an 'int1'. That's the way it was and the way
it worked, for a long time.

So I don't know if CCS has done a major change to PCD, or if it's just a
mistake due to laziness in the manual preparation. I can't help anymore
on this thread because I don't have PCD, so I'm going to quit responding.
Ttelmah



Joined: 11 Mar 2010
Posts: 19499

View user's profile Send private message

PostPosted: Tue Jan 21, 2014 2:09 am     Reply with quote

If you want to be compatible with PIC18 code, you need to use the TYPE statement, and force the use of unsigned by default.
Personally I've got into the habit of including 'stdint.h', and using uint8 in any code I want to be portable between the chips. Much easier....

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