3 Replies Latest reply on Jun 17, 2020 9:44 PM by NoTa_4591161

    UART to output with printf() function - A simple program for beginners using Modus Toolbox2.1 with PSoC6(M4)


      Hi all,


      I am making some programs for beginners using Modus ToolBox 2.1. When migrating the development environment from PSoc Creator to Modus, I had a hard time creating a simple program.

      Here, a simple program for the M4 core of PSoC 6 using  Modus Toolbox2.1 is introduced here.


      The environment is as follows.




      Last time, I used UART by setting SCB with the Device Configuration tool, but there is a library that can use the printf() function more easily. It's also used in the "Hello World" example, but here's an extract of only the UART output settings using printf () with Retarget IO Library.


      Select the CY8CKIT-062-BLE kit from the New Application tool in the Quick Panel and use it based on what was created in the empty PSoC 6 app.


      The Device Configuration tool in the IDE of Modus Toolbox2.1 is not used for Pin and UART related component settings.

      Launch the Library Manager from the Quick Panel to add the Retarget IO Lib to your project as follows.


      Go to the “Libraries” tab in the Library Manager and check retarget-io.

      After checking, click the “Apply” button at the bottom right to close the Library Manager.

      Then all you have to do is write the program.



      The program is as follows.


      #include "cy_pdl.h"
      #include "cyhal.h"
      #include "cybsp.h"
      #include "cy_retarget_io.h"
      int main(void)
          cy_rslt_t result;
          /* Initialize the device and board peripherals */
          result = cybsp_init() ;
          if (result != CY_RSLT_SUCCESS)
          result = cy_retarget_io_init(CYBSP_DEBUG_UART_TX, CYBSP_DEBUG_UART_RX, CY_RETARGET_IO_BAUDRATE);
          if (result != CY_RSLT_SUCCESS)
         /* \x1b[2J\x1b[;H - ANSI ESC sequence for clear screen */
          printf("PSoC 6 MCU: Hello World! Example \r\n\n");
          for (;;)


      Since I used TeraTerm as a terminal, the setting is described below.


      Note: “Port” is depending on the PC environment.


      It's very easy. Please use it for debugging in the Modus Toolbox environment.