There must be a simple method to display a message in the console without using the tracing. Every time you debug your code, you need to start tracing. Unfortunately, there is still a hassle using this method. Use Serial Wire Viewer (SWV/SWO) via printf to debug STM32 in STM32CubeIDE. When you run the code, make sure start tracing is enabled:Ī detailed guide on YouTube can be found in 5. Open up the SWV ITM Data console settings and make sure the port 0 is ticked (see the image below): Now you should have enabled SWV data console. In the debug configuration, enable the SWV tracing and set the core clock to the SYSCLK of your device (see the image below).ĭebug your code and go to Windows → Show view → SWV → SWV ITM Data console Those who are having the same problem, just follow these simple steps:Īdd a custom _write function to syscalls.c or even main.c: int _write(int file, char *ptr, int len) Am I missing some additional configuration? However, I cannot understand why I am not able to see messages displayed on the STM32CubeIDE console. When I open up a terminal and connect to the device, I can see the messages coming as expected: HAL_UART_Transmit(&huart1,uart1_data, sizeof(uart1_data), 50) // just to see what happens HAL_UART_Transmit(&huart3,uart3_data, sizeof(uart3_data), 50) // just to see what happens Printf("UART Printf Example: retarget the C library printf function to the UART \n\r") * Initialize all configured peripherals */ Initializes the flash interface and the Systick. Uint8_t uart1_data = "Hello from UART 1" Uint8_t uart3_data = "Hello from UART 3" HAL_UART_Transmit(&huart3, (uint8_t *)&ch, 1, 0xFFFF) #define PUTCHAR_PROTOTYPE int fputc(int ch, FILE *f) #define PUTCHAR_PROTOTYPE int _io_putchar(int ch) So far, I have been suggested to add a few lines of code that apparently should have fixed the issue, but it didn’t: #ifdef _GNUC_ I am just using a USB cable with a built-in ST-LINK to program the device. I have just generated a brand new project with STM32CubeMX and used a default configuration for the Nucleo board. I have gone through numerous forum threads and discussions and none of them appear to have fully solved this weird issue that is well known. For the last couple of days I have been trying to get printf to work to print a debug message to a STM32CubeIDE console. 1 For the last couple of days I have been trying to get printf to work to print a debug message to a STM32CubeIDE console.
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |