Serial port issues- debug port appears to be delaying system execution by almost a second!

08 Dec 2017

I am using the K64f.

In my code I am reading the second UART on this board (pins D0 and D1) and printing the time it takes to read and process the data from this second UART to the USB debug serial port.

Here is the code:

no problem

int main()
{
    pc.baud(57600);
    printTime();
    gps.SetRTC();
    gps.RTCUpdated(&printTime);
    while (true) {
        perf.start();
        gps.Update(); //does a while readable on the second UART 
        perf.stop();
        float gpsSec = perf.read();
        pc.printf("%f\n", gpsSec);
        perf.reset();
    }
}

Here is the result of the execution time: /media/uploads/joeh/no_issues.png

Whens I change the line where it prints to the debug port from:

pc.printf("%f\n", gpsSec);

to:

pc.printf("%f, %f\n", gpsSec, 0.0);

This is now the result of the execution times... /media/uploads/joeh/issues.png

Please could someone explain this, is this a bug, I have tried different baud speeds of the debug port, the UART the gps is attached to is at 9600 baud.

08 Dec 2017

I feel I should mention that the function in the callback

gps.RTCUpdated(&printTime);

has a printf, although the callback 'printTime' is never called in the above execution time test.