i.MXRT1060 Middleware Pack  Version 1.0.0
MDK-Middleware examples and CMSIS-Drivers for NXP i.MXRT1060 devices
 All Files Pages
printf retargeting

If you wish to use printf-style retargeting via the UART, follow these steps:

  • In the Manage Run-Time Environment window select:
    • Device:SDK Utilities:debug_console
    • Compiler:I/O:STDOUT User
    • Compiler:I/O:STDIN User
    • Compiler:I/O:STDERR User
      printf_components.png
      Required components for printf debugging
  • Copy the file retarget_user.c from <PACK_root>\Templates to \<project_dir> and add it to the project
  • In the Project window, browse to Device:fsl_debug_console.c, right-click and select Options for Component Class 'Device'. On the C/C++ tab, define fputc=fputc_sdk fgetc=fgetc_sdk.
    define_console.png
Note
You need to install the Mbed Windows serial driver to be able to communicate via printf/UART. Download and install the driver from here: Windows serial driver.

Continue by building and debugging the project.