Skip navigation
Home > All Places > ModusToolbox > Blog > 2019 > January

I previously wrote about using the New Application wizard in ModusToolbox and showed you the BlinkyLED project. Now I want to show you another template that I believe will be more useful to you in the long run. It is called PioneerKitApp and it supports both the PSoC 6 Pioneer kits - CY8CKIT-062-BLE and CY8CKIT-062-WIFI-BT. When you highlight the template in the wizard it tells you the following about the project.


Basic peripheral configuration for the PSoC 6 Pioneer kits (CY8CKIT-062-*). Debug is enabled and platform clocks are set for high performance (144MHz CLK_FAST for CM4 core and 72MHz CLK_SLOW for CM0+) but with a peripheral-friendly CLK_PERI frequency (72MHz). In addition the user LEDs and switch, KitProg3 UART and I2C bridges, and CapSense buttons and slider are  configured.

ModusToolbox templates

My job involves creating a lot of projects and almost every one of them blinks an LED or prints a message to the UART at some point. Depending upon how well my day is going the message might be "PSoC Rocks!" or, if things aren't going so well, something a little less repeatable! But I digress, the point is that I get really fed up of configuring pins and UARTs every day.  So I created a template and my boss told I should share it with you.


When you create the application ModusToolbox opens up the file setup_readme.txt automatically. This file describes all the settings I made in the configurator tools... clocks, pins, UART, I2C and CapSense. This means I can start programming without even opening the configurators. For example, here is a program to print a message and toggle an LED. I wrote this code immediately after creating the application without worrying about configuring peripherals, adding middleware (to support printf), picking libraries, choosing part numbers, setting include paths, or any of that nonsense.


#include "cy_device_headers.h"

#include "cycfg.h"

#include "cycfg_capsense.h"

#include "stdio.h"


int main(void)


    int count = 0;

    cy_stc_scb_uart_context_t uart_context;




    Cy_SCB_UART_Init( KIT_UART_HW, &KIT_UART_config, &uart_context );

    Cy_SCB_UART_Enable( KIT_UART_HW );




        Cy_GPIO_Inv( KIT_LED1_PORT, KIT_LED1_PIN );

        printf( "Message #%d\r\n", ++count );

        Cy_SysLib_Delay( 500 );




Let's dig in a little. First of all, notice that I am using printf(), which is defined in the usual C stdio.h header file. This is supported by the retarget_io middleware package that adds three files to the application - retarget_io.c, stdio_user.c and stdio_user.h - which you can see highlighted in the project here.

ModusToolbox printf

The "user" files are placed into the Source folder because they are intended to be user-modifiable. In the template I already did that to choose the serial block for the KitProg3 serial-USB bridge (so I can see the output in a PC terminal emulator like teraterm). Here are the settings I made in stdio_user.h.


#include "cycfg.h"

/* Must remain uncommented to use this utility */






Where did that KIT_UART_HW macro come from? Or the KIT_LED_PORT macro for that matter? Well, they got set up in the device configurator. Here is a screenshot of the device configurator, where I have called the serial communication block #3 "KIT_UART" and given it the personality UART_v1.0 (I could have used I2C or SPI instead).

ModusToolbox templates and printf middleware

The configurator generates the KIT_UART_HW macro and the KIT_UART_config variable automatically, so writing the code is easy and fast. I did a similar thing for the LEDs, giving the orange LED the alias "KIT_LED1" so that the tool generates the PORT and PIN macros for me.

ModusToolbox configuration

Next time, I'll show you a variation of this template that sets up FreeRTOS for you so you can get multi-tasking in no time at all.

A few weeks ago I announced that ModusToolbox 1.0 was released and available for download. I think it's time to start posting some pointers on how to use the product effectively. I think a good place to start that is to explain the options you have when creating new projects.

First of all, I recommend you resist the temptation to use the "File->New" dialog to create a C or C++ project. We have created a shortcut for you, with the catchy name "ModusToolbox IDE Application" that is a lot easier to use than starting the project from scratch. You *can* create your own project but you'll have to figure out how to handle the PDL libraries, and code for the CM0+ core in the PSoC 6, and the generated configuration files and, all in all, it is just way easier to use the shortcut! Just click on the shortcut in the Quick Panel or the New Project dialog.

Opening the ModusToolbox New Application Wizard           Opening the ModusToolbox New Application Wizard

Our wizard walks you through the selection of the target and a starter template for the application. You can either pick a board or choose a specific target part number. The "Custom Hardware" option is really intended for users going to market and using their own hardware. Given that ModusToolbox was released two weeks ago I am going to make the wild guess that most of you are just starting out and have one of our kits. The "Dev/Eval Kit" path is for us.


Choose target hardware dialog in ModusToolbox

Here is the list of supported kits - not too many today but we are busy working on new kits and shall be adding support for them in the future.

Choose the dev/eval kit

I have a CY8CKIT-062-WIFI-BT kit, but I think many of you will have the 062-BLE version, because that has been on sale for a while longer. Either way, pick your board and follow along - the process is the same whichever board you have. You then get a list of applications for the kit.

Choose a starter template

These are typically not full-blown reference products but rather examples of useful things to do and good places to just get started. I strongly recommend creating your own projects with a few of them - to get a feel for the tools and try out some cool stuff. The ones that are prefixed with CE are Code Examples from our Applications team so they are thoroughly tested and meticulously documented.

Most of the others are a little less formal and just show off a feature or function as quickly as possible. Let's start with "BlinkyLED", as I have in the above image. Here is the generated application.

BlinkyLED projects

The first thing you'll see is that there are actually 5 projects in an application - I'll try to be consistent in using "application" to refer to whole shooting match and "project" when I mean a specific Eclipse project. The 5 projects are as follows:

  • BlinkyLED_mainapp - this contains the code that runs on the CM4 core (your project)
  • BlinkLED_mainapp_psoc6pdl - this contains the driver code from the PDL which will be built for the CM4 core
  • BlinkyLED_config - this project contains the generated source code from the ModusToolbox configurator tools (more on this next time)
  • BlinkLED_mainapp_cm0p - this contains the code that runs on the CM0+ core
  • BlinkLED_mainapp_cm0p_psoc6pdl - this contains the driver code from the PDL which will be built for the CM0+ core

Our application - and almost certainly all of your's too - is in the BlinkyLED_mainapp project. In the source folder, double-click the main.c file to see the code we are going to run. Connect you board to the USB port of your PC and, in the Quick Panel, press "BlinkyLED Program (KitProg3)" (or change the prefix for whatever you named your application).

BlinkyLED Program (KitProg3)

If all is well you will build the application, program it, and see the blinking LED. You are now ready to start modifying the code to get used to the IDE and also trying out a few more of the examples. In my next post I'll talk about some of these templates in more detail and show you everything they automate in the generated applications.