Sravanthi Chalasani

integer overflow - DEMOJM board using MC9S08JM60

Discussion created by Sravanthi Chalasani on Nov 5, 2010
Latest reply on Nov 10, 2010 by bigmac

Hello Everyone,

 

I am using the DEMOJM Board with the 8 bit MC9S08JM60 processor mounted on it. I am using codewarrior version 6 for developing the application. I am facing a problem while performing a simple subtraction over a set of raw values read by the ADC channel.

 

I had to declare the variables as signed int and I see that, if the difference between the raw values  is either 0 or -1, an overflow occurs and I get -256 or 255 randomly.

 

I am declaring the variables as signed integers. ( say signed int diff =0).

 

Is there any other way i need to declare the variables?

 

This is the first time I am using Codewarrior and I am a beginner in Firmware developement.

 

Thank you,

schalasa

Outcomes