cancel
Showing results for 
Search instead for 
Did you mean: 

ADC Failed to execute MI command: -var-create - * step Error message from debugger back end: -var-cr

SMusc.1
Associate III

STM32U5 series

Hi, I am tring to read analog voltage from ADC on this board: STM32 U575ZIT. Using this code:

......

char msg2[15];

......

while (1)
  {
    /* USER CODE END WHILE */
 
    /* USER CODE BEGIN 3 */
      HAL_ADC_Start(&hadc1);
  HAL_ADC_PollForConversion(&hadc1, 300);
 
  raw = HAL_ADC_GetValue(&hadc1);
  float vin = raw*(5/16384);
  sprintf(msg2," vol = %.2f\r\n",vin);
  HAL_UART_Transmit(&huart1, (uint8_t*)msg2, strlen(msg2), 300);
  HAL_Delay(1000);
  //sprintf(msg2," vol = %2.f\r\n",vin);
  }
 
but any time the follow error happend, and on one selected com, i see any time 0.000000
 
1) Failed to execute MI command: -var-create - * step Error message from debugger back end: -var-create: unable to create variable object
2) Failed to execute MI command: -var-create - * step Error message from debugger back end: -var-create: unable to create variable object
3) Failed to execute MI command: -data-evaluate-expression step Error message from debugger back end: No symbol "step" in current context.
4) Failed to execute MI command: -var-create - * step Error message from debugger back end: -var-create: unable to create variable object
5) Unable to create variable object
 
how is possible.
If i try to send only charatters on the com without using ADC, on the selected com i am able to see the data.
Any help please

 

1 REPLY 1
TDK
Guru

>   float vin = raw*(5/16384);

This evaluates to zero, since (5/16384) = 0. Perhaps you want:

   float vin = (float)raw * 5.0f / 16384.0f;

 

If you feel a post has answered your question, please click "Accept as Solution".