Hello Embedded Developers,

 

This is a follow-on to my blog post on using ModusToolbox from the Windows command line. In this example, I add configurators to the mix. In this post I will

  1. Adjust my pinout with the ModusToolbox Device Configurator, launched from the command line
  2. Observe CapSense signals with the CapSense Tuner (launched from the Device Configurator or from the command line).

I’ll also going to show the how to set a make variable on the command line and get help with the various make variables and targets Cypress provides in ModusToolbox.

 

Remember to have your environment set up similar to what is described in the previous blog post. This means:

  • We need GNU make, such as might be found in Cygwin and
  • An environment variable called CYSDK that points to the ModusToolbox installation. In my case have the following two lines in my Cygwin .bash_profile.

    

     CYSDK=C:/Users/mdl/ModusToolbox_1.1

     export CYSDK

 

I have also set up my path to make it easier to launch the tools I am interested in running.  Here are the lines I have in my .bash_profile.

...

# I want to run several ModusToolbox tools from the command line

# The following is how I manage that. You don’t have to use this variable

MTB_TOOLS=/cygdrive/c/Users/mdl/ModusToolbox_1.1/tools

 

# Add the ModusToolbox Device Configurator (allows me to do things like change the pinout)

PATH=$MTB_TOOLS/device-configurator-1.1:$PATH

# CapSense Configurator and CapSense Tuner

PATH=$MTB_TOOLS/capsense-configurator-1.1:$PATH

...

 

Again, start with an example template

In my case, I’m going to start with CapSenseSlider, which is found here $INSTALL\libraries\psoc6sw-1.1\examples\CapSenseSlider

  1. Copy that whole directory over into a clean workspace, for example, C:\Users\<User>\Desktop\CapSense.
  2. Open a Cygwin terminal and go to that directory.
  3. Once you are in that project directory, go to the Source subdirectory and open (or just view) main.c.  Instructions for this example are shown in the comments at the top of the file.  For this walk through, I am using a CY8CPROTO-062-4343W kit.  So, from the instructions I can already see I’ll need to change the pins as the pin assignments for this example are, by default, set up for the CY8CKIT-062-BLE kit or the CY8CKIT-062-WIFI-BT Kit.

 

Here is an excerpt from main.c of the CapSenseSlider example template.

 

...

* Migration to CY8CPROTO-062-4343W kit (ModusToolbox IDE):

*   1. Create this project targeting the CY8CPROTO-062-4343W kit.

*   2. Open design.modus file and replicate P0[3] configuration on P13[7]. Give

*      this pin the alias "LED_RED". Disable P0[3].

*   3. Build and Program

*

* Migration to CY8CPROTO-062-4343W kit (command line make):

*   1. Launch the Device Configurator tool from

*      ModusToolbox_x.x\tools\device-configurator-x.x\

...

 

Set up the pin that drives the LED

 

4. Go up one level in the hierarchy from main.c and from the Cygwin command line type

 

device-configurator design.modus

 

You should see a window similar to the following

 

 

5. Click on the Pins tab to modify the assignments.  According to the instructions in main.c, we will need to replicate all the settings from P0[3] (Pin 3 on Port 0) to P13[7] and disable P0[3]. P13[7] corresponds to LED4 on the board I am using.  Here is a screen shot showing LED4, near the center of the CY8CPROTO-062-4343W board (see red rectangle).

 

 

6. Here is what the settings for P13[7] look like after the edit.

 

Note the alias, LED_RED. That is important. That is how we will be referencing that signal in our code.  If you like, search for the string LED_RED in main.c.  You will see code such as

 

Cy_GPIO_Write(LED_RED_PORT, LED_RED_PIN, redLedState);

 

Cy_GPIO_Write is the API Cypress has provide to write a value to a GPIO.

 

7. Save your new pin configuration (File->Save)

8. Fortunately, pin assignments for the CapSense buttons and slider segments don’t need to be changed since they are the same across several Cypress boards (e.g. CY8CPROTO-062-4343W, CY8CKIT-062-BLE, and CY8CKIT-062-WIFI-BT).

9. I’ll show you how to launch the CapSense Tuner later in this post, but first let’s just see if we can make LED4 turn on and off with the button, BTN0. Make sure you are in the project directory (that is, the one with the design.modus file).

10. Since we’ve modified pin assignments, let’s be safe do a make clean from the command line.

11. Plug in your board to a USB port on your computer using a USB cable. Make sure you that on the board you plug into the USB port that is the Program/Debug USB port on the top-left (when the board is oriented so the CapSense slider is on the bottom). The other USB port is for the PSoC 6’s USB.

 

Build your application and program the board

 

12. Now type make DEVICE=CY8C624ABZI-D44 program

 

Specifying the Make variable DEVICE=CY8C624ABZI-D44 overrides the default targeted device and targets instead the particular PSoC 6 on the board I am using. The make target named program will launch the appropriate tools to download the program from you computer to the board (flash the part).

 

Recall from the previous blog post that the first build of a given project will be substantially longer than future builds.

 

If you want to know more about the make variables available with ModusToolbox, refer to the document Running ModusToolbox from the Command Line. You can also just type make help in a ModusToolbox project directory to get a plethora of information (see the following screen shot for a partial list)

 

 

13. After a successful build, you should be able to repeatedly touch BTN0 on the board to toggle LED4.  You may need to press SW1 (RESET) first.

 

Observe what’s happening with the CapSense sensors using the CapSense Tuner

 

We can watch what happens when each of the sensors are pressed in the CapSenseTuner, which can be launched from the command line in two ways. The first method is to launch it from the Device Configurator. The second is to launch the CapSense Tuner directly from the command line. I'll show both ways.

 

First from the ModusToolbox Device Configurator.

  1. Launch the Device Configurator, as described earlier in this post, that is device-configurator design.modus
  2. Switch to the Peripherals tab
  3. Expand the System group if it’s not already expanded.  You will see that CapSense is enabled (see check mark).  Your window will look something like this

4. Select the CapSense row

5. Launch the CapSense Tuner from the right side under External Tools (see the following screen shot)

 

6. Once the CapSense Tuner window opens

    • Select Communication->Connect KitProg3 UART-[some string]->I2C
    • Select the Widget View if not already selected
    • Select everything in the Widget Explorer
    • Connect (click the round, green button, press F4, or select Connect from the Communication menu)
    • Start (click the triangle pointing to the right, press F5, or select Start from the Communication menu)

     If you forget those last two steps (Connect and Start), the output will be quite boring.

7. Now, touch BTN0 on the board and observe that Button0 in the middle window of the appliation will turn blue. Also notice the blue graph bar in the Touch Signal Graph Window on the right side of the application. It will look something like following screen shot.

 

 

You can also launch the CapSense Tuner directly from the command line (Instead of launching from the ModusToolbox Device Configurator),

That’s done as follows:

 

  1. From the command line, type capsense-tuner
  2. Choose File->Open from the tool menu
  3. Navigate to [Project Directory]/GeneratedSource folder and select cycfg_capsense.h

 

Remember that I have the CapSense tuner set up in my path via my .bash_profile.  You can also launch it directly from $Install\tools\capsense-configurator-1.1 (depending on your version of ModusToolbox, you may need to replace 1.1 with the proper substring).

 

Now, run your finger across the CapSense slider and watch the results in the CapSense Tuner Application (make sure all the sensors are selected on the left). Again, don't forget to connect and start in the CapSense Tuner application. The application will show something like this

 

That it for this post.  You can follow similar steps for other ModusToolbox configurators. In future posts, we’ll show other things, such as the Mbed command line flow.  Let us know in the comments if there is something specific you would like to see.

 

--Matt