I want to use printf
on STM32F107 and I have the problem that my program sends the printf
messages just after 1024bytes.
Here is my overwrite code:
int __io_putchar(int ch) {
uint8_t c[1];
c[0] = ch & 0x00FF;
HAL_UART_Transmit(&huart1, &*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;
}
And here the sample Code for output:
while (1) {
printf("Test %d", testcnter++);
//HAL_UART_Transmit(&huart1, "TEST", 4, 100); <-- Works prints every loop
HAL_Delay(250);
}
Here is the Output: