Skip to main content
Senior
November 25, 2024
Question

printf() not working

  • November 25, 2024
  • 2 replies
  • 575 views

I have used this method many times on this board (Nucleo-H743ZI) to transmit printf() to usart3 using the following:

 

int __io_putchar(int ch) {
 /* e.g. write a character to the USART3 and Loop until the end of transmission */
 HAL_UART_Transmit(&huart3, (uint8_t*) &ch, 1, 0xFFFF);
 return ch;
}

[...]
printf("hello world\n")

 

However, it has now stopped working in my project. HAL_UART_Transmit() still works fine but printf never seems to call __ioputchar.

This same thing is working on my project with the STM32H7B3I-DK, using usart1.

Any Ideas what could've happened?

This topic has been closed for replies.

2 replies

Tesla DeLorean
Guru
November 25, 2024

Review with a debugger?

Disassemble, check the library linkage, and understand where in the path from printf() to __ioputchar() it is failing.

syscalls.c ?  _write() ?

Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..
Senior
November 25, 2024

 

From viewing the disassembly I can see it gets to __io_putchar with the following disassembly.. it doesnt look like its getting into the __ io_putchar that I defined

112 		__io_putchar(*ptr++);
08003718: ldr r3, [r7, #8]
0800371a: adds r2, r3, #1
0800371c: str r2, [r7, #8]
0800371e: ldrb r3, [r3, #0]
08003720: mov r0, r3
08003722: nop.w