2019-08-01 10:46 AM
I am working with the attached code, and I am acquiring data from an extern ADC, using SPI communication. Also, I am using USB OTG FS communication to receive data from the computer, but when I add a simple code line that just multiplies a variable, the USB communication does not work, but when I delete this line, the USB works again, which doesn't makes sense.
The mentioned code line is
PID_X.Tunel_Current=((float)(USB_Communication.Send_Union.Send_Struct.Dat_P3[2]-131074)*0.0001953);
This code works perfectly in Keil, but in STMCUBE_IDE does not.
If I don't include the last multiplication ( *0.0001953 ), the code works fine on STM32CubeIDE. I don't understand why is this happening; this kind of behavior shouldn't be present in such an important IDE. I really don't want to switch back to Keil, but so far, seems the only option.
Please help
void Analog_Digital_Converter::Get_All_Value_Adc(){
if(Analog_Digital_Converter::adc_get_value){
USB_Communication.Send_Union.Send_Struct.Dat_P3[2] = Analog_Digital_Converter::ADC_GetValue(Select_input_Ch_2,GPIO_PIN_9);
USB_Communication.Send_Union.Send_Struct.Dat_P3[3] = Analog_Digital_Converter::ADC_GetValue(Select_input_Ch_3,GPIO_PIN_9);
USB_Communication.Send_Union.Send_Struct.Dat_P3[4] = Analog_Digital_Converter::ADC_GetValue(Select_input_Ch_4,GPIO_PIN_9);
USB_Communication.Send_Union.Send_Struct.Dat_P3[5] = Analog_Digital_Converter::ADC_GetValue(Select_input_Ch_5,GPIO_PIN_9);
USB_Communication.Send_Union.Send_Struct.Dat_P3[0] = Analog_Digital_Converter::ADC_GetValue(Select_input_Ch_0,GPIO_PIN_9);
USB_Communication.Send_Union.Send_Struct.Dat_P3[1] = Analog_Digital_Converter::ADC_GetValue(Select_input_Ch_1,GPIO_PIN_9);
PID_X.Tunel_Current=((float)(USB_Communication.Send_Union.Send_Struct.Dat_P3[2]-131074));
PID_X.Tunel_Current*=0.000019531;
}
}
2019-08-01 11:32 AM
One is a professional tool, the other isn't?
2019-08-01 12:26 PM
Hardware or software floating point? Stack space? RTOS or no RTOS? Is this in a interrupt routine or main code? Is the Keil compiler keeping the multiply as float and the BCC compiler promoting it to double, or vice versa, causing more or less stack usage? What about a different linking order between IDEs/compilers (RAM variables and functions in different locations) so some latent bug somewhere else in the code (screwy pointer access) is made visible with the BCC compiler by adding that one line of code?
2019-08-01 05:25 PM
it would be good if we could have good alternative to Keil and IAR that is directly supported by ST and other features not locked behind paywall