6 years, 11 months ago.

possible conflicts using printf() and instance->printf()

Hi ... i'm using two serial ports on nucleo F767ZI. One port is the usual serial port to be used via USB. Something like a console. I need the direction from NUCLEO board to PC only. The second port, UART-2, is used to exchange data with a Sensor. There i need both directions - RX and TX. For the console output i simply use the printf-statement w/o specifying the serial port. For the sensor i have set up an instance of Serial specifying the pins PD_5 and PD_6 for TX and RX respectively (Serial usart2(PD_5, PD_6);). In addition, i use the methods instance->readable, writeable, getc, putc and printf.

The issue is that in this combination the UART-2 channel seems to end up in some kind of infinite loop. In particular the readable method does not come back if there are characters available.

If i us another Serial instance for the console port (Serial pc(USBTX, USBRX);), everything works perfectly.

The botton line ist: Why does printf() behave differently than pc->printf()?

Thanks ... Matthias

Be the first to answer this question.