whether printf uses UART FIFO

09 Mar 2010 . Edited: 29 Mar 2010

Hello everybody,

I have got my MBED just yesterday and exploring it has been great fun. I have a doubt regarding the time required for printf. Here is the code that has been implemented

#include "mbed.h"

DigitalOut myled(LED1);
Serial pc(USBTX, USBRX);
Timer t;

int main()
{
pc.baud(115200);
pc.format(8,Serial::None,1);
while(1)
    {
    t.start();
    pc.printf("Hello\n");
    t.stop();
    pc.printf("%f\n",t.read());
    wait(0.5);
    t.reset();
    myled = 1;
    wait(0.5);
    myled = 0;
    }
}

The result was:

Hello
0.000360
Hello
0.000367
Hello
0.000359
Hello
0.000359

 This routine is sending 6 characters @115200bps and 8-N-1 format

The characters need (theoratically the best) 520.833 us to complete the printf. Then i thought that maybe the UART is using the FIFO buffers because of which the time required is less. But then when i send more characters (total less than 16), the time is increasing proportionately. So i am confused whether the UART is indeed using the FIFO buffers. Can anyone throw light on this? Here is the output when i send 12 characters:

Hello World
0.000883
Hello World
0.000875
Hello World
0.000883
Hello World
0.000883
Hello World
0.000874

 

02 Apr 2010

the printf command is not using the uart, confirmed through experimentation.