cancel
Showing results for 
Search instead for 
Did you mean: 

I would like to know why the code works in Keil MDK5, but not in STM32CubeIDE

JBerm
Associate

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;
	}
}

0 REPLIES 0