2025-07-24 5:09 AM - last edited on 2025-07-24 5:44 AM by Andrew Neil
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_BUFFER
RX_BUFFER
A screenshot of Hercules receiving the correct string
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,
2025-07-24 5:47 AM
Does it make a difference if you declare the buffers as char - rather than uint8_t ?
2025-07-24 7:37 AM
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 */
2025-07-25 1:52 AM
@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*