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 support@ccsinfo.com

Pic24 int8 int16 int32 problem

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



Joined: 16 Jan 2011
Posts: 27

View user's profile Send private message

Pic24 int8 int16 int32 problem
PostPosted: Thu Apr 07, 2011 8:15 am     Reply with quote

Hi all,
Using PCD 4.118
problem is persistent
when i transfer data from int8 to int16, the msw result bits are set
same problem with int16 to int32
Code below simplified to illustrate the problem

Code:

int32 address;
int16 HighAddr;
int16 LowAddr;
int32 Rcxx;

   HighAddr=0x0003;
   LowAddr=0x8230;


   HighAddr&=0x0007;          // int16
   address=HighAddr;      // load int32 with int16
   address <<= 16;      // shift ls16 to ms16 in int32
   address += LowAddr;      // add ls16 to ls32


   Rcxx=address;
   printf(lcd_putc, "Addr=%LX",Rcxx);   // the result = 0xFFFF8230
                                 // should be    0x00038230


or

Code:

int8   Ral:
int16   Raa:

   Ral=0x84;
   Raa=0x0000;
   Raa+=Ral;          // Raa = 0xFF84 instead of 0x0084



Any ideas?
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Thu Apr 07, 2011 10:07 am     Reply with quote

Unlike PCB, PCM, and PCH, the data types in PCD are 'signed' by default.
This is in the PCD manual, this section:
Quote:
Data Definitions / Basic and Special Types

http://www.ccsinfo.com/downloads/PCDReferenceManual.pdf
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