Important changes to forums and questions
All forums and questions are now archived. To start a new conversation or read the latest updates go to forums.mbed.com.
5 years, 1 month ago.
printf not working , while serial printf is (KEIL + GNU ARM)?
Hello, I was able to fly the demo code on xDot .
- include "mbed.h"
Serial pc(USBTX, USBRX); tx, rx
int main() { printf("Not printing \r\n"); /*This is not printed*/ pc.printf("Printing\n\r");/*This is printed*/ while(1) { } } To me it seems there is something wrong with the retarget of printf. Any ideas?
1 Answer
5 years, 1 month ago.
Hi Muhammad,
printf() should use pc. Also pc.printf() should work. Without going deeper in Mbed OS I would say that if you have several Serial instances like Serial pc(USBTX, USBRX); tx, rx Serial uart2(Ptx, Prx); then pc.printf() uart2.printf() Here is more information about printf: https://os.mbed.com/docs/mbed-os/v5.10/tutorials/debugging-using-printf-statements.html
Regards, Pekka