You are here

PSoC Today! | Cypress Semiconductor

Nov 25, 2014

PSoC NeoPixel Tree Lights

When you have the option between decorating your house or tree the normal way or the nerdy way, a true engineer will always pick the nerdy path, right?  Standard strings of holiday lights are usually only one color and at most just blink.  During the last couple years you can get some LED lights that change color and make interesting patterns.  That is cool and all, but your decorations will be the same as everyone else, that buy those lights. 


If you are interested in adding a little flash to your decorations this year, there are some fun modules available that will help you do just that.  The WS2811 and WS2812 contain three LEDs, red, green, and blue, and a serial interface to control the current in each LED. These RGB LED modules are also known as NeoPixel.  Strings up to five meters long or rings of them can be found at  You can chain a thousand or more of these devices in series, controlled by a single IO pin.  The bad news is that the interface is non-standard.  Most single chip microcontrollers require you to use firmware to bit-bang the interface.  Since the WS2811/12 parts operate at 800K bits per second interface, the firmware must bit-bang at an accuracy of about +/- 150 ns.  This can easily take up 100% of the CPU time just to send the data to the LEDs!  With PSoC (3,4,5) you can create your own custom interface and easily interface to parts such as the WS3811/12.  The UDBs in PSoC allow you to load a FIFO every 30uS instead of constantly toggling a GPIO pin at speeds at less than a 1 micro second interval.


Since this component has already been created, you can spend your time coming up with cool patterns to dazzle your friends and relatives.  I have included a PSoC Creator Workspace that includes the StripLights library (for the WS2811/12) and a couple of example projects to give you an idea of how to use the component.  Both projects are built for the PSoC 4200 family, but you can change the project to use either PSoC 3 or PSoC 5LP.  Project P4_OneRing controls a single ring of these LED modules.  The second project P4_MultiRings , allows you to string multiple rings together to make your own very cool string of circular lighted ornaments.  You can find the download here at You are not limited to rings of lights with this library or the examples, you can use any combination of the LEDs to do whatever you want. So get out there and be creative with PSoC and some LEDs!



The images below show one of the 12 LED rings from, twelve of these rings wired in series, our amazing Christmas tree in my office using several of these rings, and what the project schematic looks like. 


Happy Holidays,

Mark Hastings

Jun 27, 2014

Do you put your l-values on the right?

My recent comment about tilde (~) versus pling (!) caused some comment in this neck of the woods so I thought I'd follow up with another contentious post about C programming. Where should the lvalue go in a conditional expression?

OK, that's boring terminology, so let's write a wee bit of code to make the point. Do you write this...

#define FAIL (0)

int result = whatever();

if( result == FAIL ) { }

Or this...

if( FAIL == result ) { }

The issue is, of course, that the code brings us close to the dreaded single-equals problem. The first version is emminently readable because it follows an English subject-verb-object format. Lovely. But it has a built-in risk. Mis-type that == as just an = and all hell breaks loose. Firstly, the block of code never runs, regardless of the return from whatever(). The compiler (should) optimize it all out (even if optimization is disabled this is probably going to happen - the code cannot run so why generate the instructions?). What happens in the code that might come after that block is anybody's guess! It is all a bit of an "oopsie" and we've all done it. Well you all have. Not me. No. never. Ahem. Moving on...

So, the smarty-pants amongst us reverse the expression and put the non-writable part on the left. That method means a typo is an easy to fix compiler error, not run-time wierdness. That's a great solution. But it looks strange and I hate it!

What do you guys do? Opt for safety or readability? My take, which might get me into trouble, is that while I have actually done the single-equals thing (OK, I admit it, can we move on?) I have never done so in code that I gave to someone else. I've always figured it out and, after the first time, done so pretty quickly. The end result is code that is "right" and readable.

Am I making a mature, informed decision about my C programming life or am I leaning on the "thin ice" sign-post as I strap on my skates?

May 15, 2014

Pling(!) or Tilde(~)?


If you are following the PSoC Creator 101 video series you will have seen, in today's lesson 4, a way of toggling a PSoC pin from firmware. The code does a read of the pin's current state, inverts it, and writes the new state back. It looks like this:

LED_Write( ! LED_Read() );

Pretty simple, huh? Well we thought so until the video got reviewed by our Applications team. Even though the code works perfectly, some of those guys felt that the right way to do this was with a bitwise operator:

LED_Write( ~ LED_Read() );

This started a good old-fashioned turf war. Which is the right operator to use; pling(!) or tilde(~)? Note that the Write API expects a uint8 (char) argument and the Read API returns the same type.

The bitwise proponents claimed that ~ is the true inverting operation because it flips all bits in the byte. It is commutative. Most of us had trouble spelling and pronouncing that word but we all agreed that it did sound rather fancy.

The logical guys claimed that it is a true/false operation (the state of the bit) and so the ! operator is more readable . This just made the tilde guys bit-ter because the pling argument was unfairly reusing the word logical to refer to their position as well as the operator. It was getting feisty! Or was it feisty~?

We never really resolved the argument but one bright spark did point out that the pin component is actually a pins component and can support multiple pins from a single instance. This messed everything up because, in that situation, the bitwise operator is definitely the right one to use. If you use pling then the first write will clear all the top bits permanently. That would constitute a real code defect, as opposed to a philosophical issue.

So, what's your take? Both methods pass my if it ain't broke, don't fix it criteria and, since the videos are about PSoC rather than C coding, we elected not to re-record the video. Should we?



May 01, 2014

Matt's Tips: Finding Example Projects for PSoC Creator

Users new to a tool almost always agree on one thing - more (good) examples are better!  Even experienced users don't want to reinvent the wheel.  To that end, this post will cover a few ways you can find examples for PSoC Creator.

The Example Finder

In PSoC Creator, there are a couple of ways to find example projects.  Many of you are familiar with finding example projects for particular components (I'll discuss this in a bit), but in Creator 3.X there is also an example finder accessible from the file menu. See the screenshot below.

Once you select "Example Project", you will get a search tool which allows you to customize your results based on keyword, architecture, etc.    Notice in the image below that once you select an example project from the left-hand side, there are two tabs on the right that give you more information about the project.  

(1) The documentation tab, highlighted in yellow in the screenshot, gives you a description of the project.  Sometimes the descriptions are elaborate and sometimes they are just a basic overview of what the project does.   Also notice the buttons at the bottom of the dialog box which allow you to add the project to the existing workspace or a new one.


(2) The Sample Code tab shows the code that comes with the example.  See the image shown next.  You can copy and paste code from this window if you don't want to use the example project as a basis for your new project.  I find this helpful to see how the various APIs for a given component are called.



Finding examples for specific Creator components

Most components have example project(s) associated with them.   You can find these projects by simply right-clicking on the component. See the image below.  When I right click on the themistor component, one of my options is Find Example Project .



You can bring up this menu from the Component browser as well. While this feature has been around for a while, I still run across folks who have just not noticed it.  I'm out to fix that!  I use "Open Datasheet" and "Open Component Web Page" frequently as well.


The Future

In the future, we plan on adding both more examples AND more ways to search for the examples such as by solution space or by "degree of difficulty".  What examples would you like to see?  How would you like to search for them?  Hit me up in the comments or email me directly at

Best regards to my brothers and sisters in PSoC.


Matt Landrum, PSoC Software Customer Advocate

Cypress Semiconductor- Portland, OR

Apr 04, 2014

Matt’s Tips: What if I need PSoC Creator on a machine with no (or spotty) internet connection? Can I order a DVD?

I get this question from time to time. It's not unheard of to have a machine isolated from the network for security or privacy reasons.  Sometimes you may have a lab/manufacturing machine with no need for an internet connection.  What then if you need PSoC Creator or Programmer?

Fortunately you can order a FREE DVD of PSoC Creator.  You can order it from the PSoC Creator page,, or from the link on the Downloads page (did you know we have one of those?)

Here's a screen shot from the PSoC Creator page.

Your free DVD will arrive somewhere between a few days and a week depending on whether or not we are restocking with DVDs containing the latest release.  Having PSoC Creator on DVD is a nice option for those of you that have spotty internet connections or don't want to download half a gigabyte using your home connection.

Now, what if you don't want to wait for the DVD but you need Creator installed on a machine with no internet or network access?

Answer: Use the ISO Disk Image file.  You can use that file to burn your own DVD or use software to make the file appear as though it were a DVD in a DVD drive.  We even have a KB article describing how to do that. See KBA 82939.

The ISO file may be found either on the Downloads page (yes, we have one) OR the Downloads Tab of the PSoC Creator home page.  See the screenshot below.


If you have any question on Creator DVDs or any downloading questions in general, hit me up in the comments (It may take a bit for your comment to show up. All must be approved because of all the great deals on Rolodexes out there).


Matt Landrum, PSoC Software Customer Advocate
Portland, OR


Content on this site may contain or be subject to specific guidelines or limitations on use. All postings and use of the content on this site are subject to the Terms and Conditions of the site; third parties using this content agree to abide by any limitations or guidelines and to comply with the Terms and Conditions of this site. Cypress Semiconductor and its suppliers reserve the right to make corrections, deletions, modifications, enhancements, improvements and other changes to the content and materials, its products, programs and services at any time or to move or discontinue any content, products, programs, or services without notice.