Casting error when assigning a negative int16 variable to float32 variable | Cypress Semiconductor
Casting error when assigning a negative int16 variable to float32 variable
I am working with int16 variables (which are actually 12-bit data read from SAR ADC register) and assigning the difference of two of the these variables to a float32 variable.
I defined the datatypes and initialization of the variables as below:
volatile int16 Vgrid_adc=0;
volatile int16 Igrid_adc=0;
code which has casting error is below:
Problem that I am facing:
When variable V is positive it is assigned as expected to variable Vgrid but when 'V' is negative this doesnot happen(Refer the .PNG file that contains the watch window for both the cases ). Please tell me whats wrong in the code.