Associate II
July 30, 2019
Solved
printf() not working - _write() never gets called
- July 30, 2019
- 5 replies
- 12044 views
Hello,
as the title suggest, I can't get printf() to work.
I implemented _write() in my main() but during debugging the program never get there.
The project was created with CubeIDE.
int _write(int file, char *data, int len)
{
if ((file != STDOUT_FILENO) && (file != STDERR_FILENO))
{
errno = EBADF;
return -1;
}
// arbitrary timeout 1000
HAL_StatusTypeDef status =
HAL_UART_Transmit(&huart1, (uint8_t*)data, len, 1000);
// return # of bytes written - as best we can tell
return (status == HAL_OK ? len : 0);
}I know the hardware works, because the same implementation of _write() works in an other project (the one provided here).
I am probably missing some compiler setting but I can't for the life of mine figure out what it is.
Can someone please point me in the right direction?
Best regards.
Christoph