cancel
Showing results for 
Search instead for 
Did you mean: 

error reading variable: Converting character sets: Invalid argument

Najd_Elaoud
Associate II

 

Hi everyone,

I'm currently debugging UART communication (USART3) between an STM32G070CBTx and my PC using Hercules terminal (serial software). The setup seems to be working. I can see data being sent and received. I'm monitoring the TX_buffer and RX_buffer via Live Expressions in STM32CubeIDE.

The issue is that when I try to view the contents of these buffers as ASCII characters, the debugger shows this error:

72 '<error reading variable: Converting character sets: Invalid argument>'

However, the buffer values are correctly shown as decimal ASCII values (e.g. 72 for 'H', 101 for 'e', etc.).

  • A photo of the Live Expression view showing the error

TX_BUFFERTX_BUFFERRX_BUFFERRX_BUFFER

  • A screenshot of Hercules receiving the correct string

image.png

 My question is:

Is there a way to fix or work around this character set conversion error in the Live Expression window?
Is it related to how the debugger is interpreting the memory or something I can configure in STM32CubeIDE?

Any insights or workarounds would be greatly appreciated!

Thanks in advance,

3 REPLIES 3
Andrew Neil
Super User

Does it make a difference if you declare the buffers as char - rather than uint8_t ?

A complex system that works is invariably found to have evolved from a simple system that worked.
A complex system designed from scratch never works and cannot be patched up to make it work.

Thanks for the suggestion!

I tried changing the buffer declaration from uint8_t to char, but unfortunately, I still get the same error in the Live Expression window.

Also, since I’m using HAL_UART_Receive_IT, the buffer needs to be of type uint8_t*, so I eventually had to cast it back anyway.

This is the code I used for the reception:

#define RX_BUFF_SIZE 20
char  RX_BUFFER[RX_BUFF_SIZE];
volatile uint8_t finished;
/* USER CODE BEGIN 0 */
void HAL_UART_RxCpltCallback(UART_HandleTypeDef *huart)
{
	finished = 1;	// set flag

	HAL_UART_Receive_IT(&huart3,(uint8_t *)RX_BUFFER, sizeof(RX_BUFFER));
}
/* USER CODE END 0 */
/* USER CODE BEGIN 2 */
HAL_UART_Receive_IT(&huart3,(uint8_t *)RX_BUFFER, sizeof(RX_BUFFER));
...
/* USER CODE END 2 */

@Najd_Elaoud wrote:

since I’m using HAL_UART_Receive_IT, the buffer needs to be of type uint8_t*,


It's moot now anyhow, but you could cast char* to uint8_t*

A complex system that works is invariably found to have evolved from a simple system that worked.
A complex system designed from scratch never works and cannot be patched up to make it work.