DesignSpark Electrical Logolinkedin
Menu Search
Ask a Question

Cypress PSoC 6 WiFi For All

“I suppose it is tempting, if the only tool you have is a hammer, to treat everything as if it were a nail.”
Abraham H. Maslow, Toward a Psychology of Being (1962)

The phrase “if all you have is a hammer, everything looks like a nail” is often attributed to psychologist Abraham Maslow (of the 'Hierarchy of Needs' fame) though the old English proverb he paraphrased dates back into the mists of time. As well as being a reminder to question your confirmation bias when approaching a problem, it is also a phrase to ponder when reaching for your favourite single board computer (SBC) to start a new project. Is that SBC really the right tool for the job you have in mind?

In many cases, an SBC will be the right choice: they are cheap and easy to program, allowing you to quickly wire parts together to try out an idea. But what if you want something more permanent or even have plans to commercialise your project?

That’s perhaps when you should think about using an embedded microcontroller dev board to build your proof of concept. All the main silicon manufacturers have development boards available for their microcontroller products. These dev kits are all pretty versatile and low cost, so the choice of board will usually come down to any specific technologies you are interested in using (for example, you may feel that Cypress Semiconductor have an edge in capacitive sensing technology) and how much you like the development environment(s) available for that board. If you are planning to make a commercial product, then the unit cost of the System on a Chip (SoC) that the development board is built around will also be a consideration.

If you are thinking of starting a new project that may be best suited to an embedded SoC device, then one kit to consider as your development board is the Cypress PSoC 6 WiFi Pioneer Kit (175-4669)

.

Cypress PSoC 6 WiFi-BT Pioneer Kit

The PSoC 6 device is a low-power programmable embedded system-on-a-chip aimed squarely at people developing IoT and wearable products. It features a 100MHz ARM Cortex CM0+ that can be used to maintain very low power operations and wake a more powerful 150MHz ARM Cortex M4 coprocessor when higher power processing is required.

For the Pioneer Kit, the PSoC 6 is put onto a board that gives the user access to all the internal features (using on-board KitProg2 programmer hardware) and a number of useful external features such as:

  • User LEDs (of course!)
  • A Capacitive sensing slider, buttons and proximity header
  • 4GHz WLAN & Bluetooth functionality module
  • 4” TFT display
  • Motion sensor
  • Ambient light sensor
  • 32-bit audio codec
  • PDM microphone
  • Headers compatible with Arduino 3.3V Shields and Digilent Pmods

The kit also includes a USB (Type A to Type C) cable for power and uploading programs plus 4x 4in jumper wires and 2x 5in proximity sensor wires.

Programming

At this point, concerns over programming the MCU are what usually put the brake on people’s enthusiasm. Is it going to be difficult? Will I need to understand intricate MCU arcana?

Let’s be straight here: there will be a learning curve to becoming proficient programming your PSoC 6 as it is packed to the gunwales with features; but if you are already connecting things to up to the GPIO pins of your SBC and getting meaningful results, then you have enough wit to master I/O and the main features of most MCUs.

You will need to get to grips with the PSoC Creator integrated development environment (IDE) and, if you want to use WiFi, the Eclipse-based WICED Studio IDE. You will also need to be familiar with the C programming language, but you are not just left to flounder: Cypress provide a large number of video tutorials, example programs, support and there is a pretty vibrant community to throw questions at too.

First Steps

The first thing we need to do however, is to connect up our PSoC 6 to our WiFi. To simplify the process, our board comes preloaded with a program that sets it up as a WiFi access point with an SSID of ‘WICED Config’:

From a Windows PC click on the WiFi connection icon on the taskabar (usually between the battery and sound volume icons) and select the connection called ‘WICED Config’. Alternatively, find: Settings -> WiFi on your smartphone to select the ‘WICED Config’ network. The password is ‘12345678’.

Once connected you can open a web browser and put ‘http://192.168.0.1’ into the address bar. This will take you to a simple page where you can select and fill in the details for your own network hub:

When the board is connected to your network, it will start an http server and then synchronise to a time server. The TFT screen will display the current PWM duty cycle settings and output voltage of the light sensor. The PWM duty cycle can be increased/decreased using the CapSense slider, while the brightness of LED5 can be changed using the Capsense buttons.

If you go back to the device you used to connect to the PSoC 6’s wi-Fi hotspot and now type in the address (on your own network this time) shown on the TFT screen into the browser bar, you will get a neat little web page giving you the time, date, light sensor voltage and PWM duty cycle.

The great thing about this simple provisioning system is that you get the source code, along with some additional features, as an example (CE222494) that you can pretty much just lift and run with to get your own project up and running in no time, whilst also showing you how to read sensors and CapSense, write to the TFT screen, use Wi-Fi in a number of ways and what you need to do to glue all these elements together.

Examples

Speaking of example software, we will need to download and install the WICED Studio IDE in order to make the most of it. All the software and documents you need to get going can be found here on the Cypress website.

WICED Studio has a standard Windows installer (plus there are instructions in the “PSoC 6 WiFi-BT Pioneer Kit Guide” pdf document) so we won’t go through the installations steps. Instead, we will look at the example program that you can use to get comfortable using the WICED IDE.

A trio of caveats to mention before we begin building and loading our first program:

  1. If you are using WICED Studio 6.1 you should apply this fix to a known issue in the implementation of OpenOCD. If you are using a later version (by the time you read this) then you probably won’t need it.
  2. Make sure you plug the supplied USB cable into the right USB C connector. Both will power the board, but you want to be using the USB C connector on the right hand side of the board (J10) to program – not the one on the top edge next to the standard USB A connector (J28).
  3. Make sure LED2 is turned off. If it is on, you are in ‘KitProg mode’ which allows you to do low level debugging on things like your flash memory using the PSoC Programmer software. However, we don’t want this when using WICED Studio, so press SW3 to put your kit into ‘CMSIS_DAP mode’ – the mode we want – which will turn off LED2.

Once you are set, we can begin following the instructions in the PSoC 6 WiFi-BT Pioneer Kit Guide for our first program.

The first thing we do is fire up WICED Studio, which can be found from the Windows Start button at Start > All Programs > Cypress WICED-Studio.

In the Target Selector drop down menu, select 43xxx_Wi-Fi.

We are going to build the ‘scan’ example which scans for Wi-Fi access points and prints out a list of what is found to a terminal through the USB port. To build and run this application, we need to construct a makefile to tell the compiler and linker how to build our application and what to do with it once built. Luckily for us, this is easily done by adding an ‘instruction’ line in the Make Target Window.

The first thing we supply is a target path: this tells the compiler where to find our code. All applications in WICED Studio need to go under the /apps directory, so our target path will need to include all the sub-directory hierarchy below the /apps directory to where our application is located. The example we want to use is in apps/snip/scan and the makefile uses dot (.) as the separator. This means we give the location as:

snip.scan

Next, we need to supply the platform name after a hyphen – so the compiler knows what microcontroller we are compiling the code for:

snip.scan-CY8CKIT_062

After that we are going to tell the software what to do with the application once it is built. For the ‘scan’ example, we want to load any application resources into the flash memory, download the application itself and reset the PSoC 6 so it starts running the application:

snip.scan-CY8CKIT_062 download_apps download run

So this is the complete line we want to add into the Make Target Window. To do that, we right-click on 43xxx_Wi-Fi in the Make Target window and click ‘New…’ in the menu that appears:

We can then add in the makefile information we have constructed into the Target Name field:

This will be added to a list of already existing makefiles. Before we build our project, it is a good idea to double-click (or right-click and select Build Target) on the ‘Clean’ Make Target. This essentially flushes the intermediate stages and output from any previous builds, so our build starts with a clean slate and compiles and links everything from scratch.

Now we can build and load our app. Find our snip.scan-CY8CKIT_062 download_apps download run target in the list of Make Targets and double-click (or right-click and select Build Target) on it:

The Resources Filesystem can take quite a long time (a few minutes) to download, so don’t panic about how long it seems to be sat there. We should end up with a blue ‘Build Finished’ message that tells us everything went smoothly. Yea!

To see what our PSoC 6 is outputting we will need a terminal emulator like Tera Term or Putty. We will need to know which ‘COM port’ to connect the emulator to. We can find that out by using the Windows Device Manager (type ‘Device Manager’ into the search box next to the windows button in Windows 10 to find it). Look down the list for COM ports and expand that entry:

OK so we know that I am using COM5. We can feed that into our Putty settings:

You need to make sure you are set to run a serial communications session. You can also save these settings for later use:

If we hit ‘Open’ we get something like this:

Our application is running as it should but if we need to debug our code, we can build a ‘debug’ version. This is built without using any compiler optimisation and allows us to add breakpoints in our code, where we can stop the execution and check that our variables are what we expect them to be at that point in the code. This debug version can be built using:

snip.scan-CY8CKIT_062-debug download_apps download

Instructions on how you might go about debugging your code can be found in the Kit user guide.

Final Thoughts

Hopefully, I have been able to show anyone who is reasonably confident with an Arduino or Raspberry Pi, that microcontrollers in general and the Cypress PSoC 6 Wi-Fi in particular, are not scary devices. With a little patience for the inevitable learning curve, you can start using the powerful resources of these devices in your own projects.

Mark completed his Electronic Engineering degree in 1991 and went on to work in real-time digital signal processing applications engineering, later moving into technical marketing.

14 Aug 2018, 9:31