ADC Failed to execute MI command: -var-create - * step Error message from debugger back end: -var-cr
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
2023-09-09 03:49 AM
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
Labels:
- Labels:
-
STM32U5 series
1 REPLY 1
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
2023-09-12 07:03 AM
> 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".
