Thank you for the reply. The complete program is
Code:
uint32_t startupRamp=0;
int16_t theta=0;
void CalculateTheta(void)
{
/* Then ramp up till the end */
if (startupRamp < END_SPEED)
{
startupRamp += 10;
}
theta += (int16_t)(startupRamp >> 10);
}
So my understanding and sequence of steps are
a. When startupRamp is 32785, its hex value is 0x8011.
b. The MSBit is 1 hence it is negative value.
c. Compiler will store the 2's complement number is 32751.
d. The computer will add a negative sign (since the MSBit is 1) and assign the value of -32751. Is it correct? Please help.