NUCLEO-H743ZI USB printf works in STM32CubeIDE but not in Keil
I have a problem with using the printf function in Keil. I used the STM32CubeMX to setup a project and generated the code for Keil.
All settings in CubeMX is standard, only thing changed is the USB_DEVICE set to Communication Device Class (Virtual Port Com).
If this is setup and genrate for STM32CubeIDE and then in main.c I add #include "stdio.h" and within User Code 4 I insert the following, then printf is working on the USB connection.
/* USER CODE BEGIN 4 */
int __io_putchar(int ch) {
uint8_t c[1];
c[0] = ch & 0x00FF;
HAL_UART_Transmit(&huart3, &*c, 1, 10);
return ch;
}
int _write(int file, char *ptr, int len) {
int DataIdx;
for (DataIdx = 0; DataIdx < len; DataIdx++) {
__io_putchar(*ptr++);
}
return len;
}
/* USER CODE END 4 */
If i then do the same thing for keil, its not working, anyone who can guide me how to solve this.
