Kyle Hamilton

UART redirection with C++ on the FRDM-K64F

Discussion created by Kyle Hamilton on Oct 29, 2017
Latest reply on Apr 18, 2018 by Ed Waldner

In trying to create a test project in C++ for the FRDM-K64F with MCUXpresso, I found that UART redirection of printf and std::count calls was not working.  After some investigation, I found that fsl_debug_console.c does not define the necessary redirection functions for Newlib (_write and _read, see Using printf()) in C++ projects.  For Redlib in C projects, the equivalent functions (__sys_write, __sys_readc) are correctly defined but for some reason the Newlib functions are missing.


The attached fsl_debug_console.c adds the missing functions and successfully redirects to/from the UART with printf, scanf, std::cout, and std::cin.


Here are the versions that I am using:

- MCUXpresso IDE v10.0.2 [Build 411] [2017-07-11] 

- MXUXpresso SDK 2.2.0