-
Add the following code:
-
Inside USER CODE Block 3:
/* USER CODE BEGIN 3 */ HAL_Delay(500); HAL_GPIO_TogglePin(GPIOI, GPIO_PIN_1); printf("LD1: %d\n\r", HAL_GPIO_ReadPin(GPIOI, GPIO_PIN_1)); } /* USER CODE END 3 */
-
Inside USER CODE Block 4:
/* USER CODE BEGIN 4 */ #ifdef __GNUC__ #define PUTCHAR_PROTOTYPE int __io_putchar(int ch) #else #define PUTCHAR_PROTOTYPE int fputc(int ch, FILE *f) #endif /* __GNUC__ */ { HAL_UART_Transmit(&huart1, (uint8_t *)&ch, 1, 0xFFFF); return ch; } /* USER CODE END 4 */
-
Inside USER CODE Block Includes
/* USER CODE BEGIN Includes */ #include <stdio.h> /* USER CODE END Includes */
-
-
"Build Project" --> "Debug As --> 2 STM32 C/C++ Application" to enter Debug Perspective.
-
Before pressing "Resume" button to run your code, let's activate STM32CubeIDE UART console
-
Press "Resume" button in Debug Perspective and message will be printed in the console:
-
Let's move on to the next topic still regarding printf.