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

32Bit preprocessor calculation

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



Joined: 16 Apr 2007
Posts: 1

View user's profile Send private message

32Bit preprocessor calculation
PostPosted: Mon Apr 16, 2007 8:55 am     Reply with quote

Hello

Has anybody some experience with perprocessor calculations?

Because of a user friendly handling I need some unique calculations. It is necessary to do them with the preprocessor because I work with a Pic10F202 and with 512k ROM I've not enough memory left to do them in the program.

Me problem is now the calculation returns a 16Bit value but the real result is a 24Bit (32 Bit) Value. Is there a possibility to tell the compiler to calculate with 32 Bit values?

Piece code:

Code:

#define     RUN_TIME        1       //Set Run Time in d (0 - 814) (resolution 2.304s)

#define c_RUN_TIME         (RUN_TIME*(24*3600*1000000)+128*128/2)/(128*128)   //int32


int32   RH_Counter;    //RunTime and Hipernation Counter

void init(void){   
   //Init Timer
   setup_timer_0(RTCC_INTERNAL|RTCC_DIV_1);setup_wdt(WDT_18MS);
   
   //Init global variables
   RH_Counter = c_RUN_TIME;
}



If I look into the Lising file. The compiler translated the variable initialisation like this:

Code:

....................    //Init global variables
....................    RH_Counter = c_RUN_TIME;
019A:  CLRF   15
019B:  CLRF   14
019C:  MOVLW  77
019D:  MOVWF  13
019E:  MOVLW  5E
019F:  MOVWF  12


He initializes the variable RH_Counter with the Value 0x775E instead with the real result of the calculation above witch is 0x50775E.

Has anybody a idea how to solve this problem?
Thanks for your reply
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Mon Apr 16, 2007 11:41 am     Reply with quote

I suggest that you first get it running in MSVC and prove that it works
there. Then move it to CCS.
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