8 years, 9 months ago.

printf does not work but pc.printf works- STM32F401RE

Hi,

When i use printf , I do not get any debug msg on teraterm or putty with the latest mbed library, but messages come only when i use it as pc.printf. However with the older mbed library both printf and pc.printf works. I am using quite a stable GCC ARM compiler version gcc-arm-none-eabi-4_9-2015q2.

Many of the files that I use are C and they have printf.

I already tried fflush(stdout); and also using \n everywhere in printf. Any clue as to why the latest mbed library does not work with printf ?

- ykd

I use

printf example

#include "mbed.h"
Serial pc (USBTX,USBRX);
main()
{
  pc.baud =115200;

  printf("Test me ..hello \n");  //This does not work

  pc.printf (" Wow...World \n");  //This works

}

Quick check on github does not show any recent changes in the F401 hal code for mbed. Can you do a quick check for the online compiler? Might hint if it is the source code or the exporter options.

posted by Erik - 26 Jun 2015

Hi Erik,

I took the standard nucleo_printf example and built it using online compiler and then tested it on both F401/F411 hardware. Again in this case only pc.printf works and anything in printf did not work. Looks to me its something to do with HAL code as binary from online compiler does not work for printf.

include the mbed code printf

#include "mbed.h"
Serial pc( PA_11,PA_12);

DigitalOut myled(LED2);
 
int main() {
  int i = 1;
  printf(" Good Morning\n");  //This still does not work
   while(1) { 
      wait(1);
      printf(" Test the world\n");  //Does not work
      pc.printf("This program runs since %d seconds.\n", i++); //Works fine
      myled = !myled;
  }
}
posted by yogesh kulkarni 29 Jun 2015

is it necessary to divert printf to something specific when I am not using the standard (USBTX,USBRX) , but PA_11 and PA12 ? Where can I do this if i have to change ?

posted by yogesh kulkarni 29 Jun 2015
Be the first to answer this question.