Exploring the PSoC 4

The PSoC architecture sits somewhere between an MCU and an FPGA. In addition to a processor core, it contains programmable analog and digital fabric.

Recently, I was asked to design a two-channel signal converter from a bipolar input voltage to a bipolar output current. I immediately assumed that this was going to be a pure analog design, but there was something that niggled at me. One of the explicit requirements was that each channel was to have a bi-colour LED that varied in brightness proportional to the input signal, and that changed between green and red to indicate when the signal was positive or negative, respectively.

There were two issues. First, the LED drive would need to be boosted so that there is no dead zone around zero. Second, I could foresee a condition where the signal would be negative, but the LED (and possibly the output) was positive, and vice versa. The mechanical equivalent of this is called backlash. Rather than drive the LED with a variable voltage, I considered using a PWM (pulse-width modulated) driver like the LTC6992 from Linear Tech, but I would still have to generate an offset and it didn't solve the backlash issue. Also, I would need two of them (one per channel), and there would have to be additional circuitry to change from red to green. Thus, it was a logical jump to look at low-end microcontrollers (MCUs).

I started off by looking at Microchip, but the ones I found were of the 16C family with small memories, which meant using assembly language. I have worked on three projects with the 16C family (five if you include the Scenix/Parallax SX28 which used the same opcodes as the Microchip), and I am afraid I never felt at home with the paucity of instructions (it being a RISC device) to say nothing of the memory segmentation issues. Succumbing to my bias, I then looked at NXP devices and Freescale ARM Cortex-M0 chips. There are so many variations to choose from that I balked at them as well.

Additionally, sometime ago we started a project using Freescale's CodeWarrior Development Studio (that project was significantly more complex than the project in this column), but we discovered we would need to pay for support to obtain the response that we needed. Add another bias to my psychology.

Now, I will be the first to tell you that I am a fan of PSoCs (Programmable SoCs) from Cypress Semiconductor. I have worked on many smaller projects with the PSoC 1 and one large project with the PSoC 5; also, I had heard some hype about the PSoC 4, which is ARM Cortex-M0-based. I looked at the price of the PSoC 4 and I was pleasantly surprised.

Fortunately, my project had some maneuverability on price, and I am aware that the flexibility of the PSoC configuration normally has some payback with the reduction of external devices. Of course, we already have the emulator and some experience, so I decided to look into this device further with the aid of the PSoC 4 Pioneer Kit (Arduino shield compatible). This kit uses the versatile PSoC 4200 family, so that was the starting point of my project.

Cypress provides a great development environment called PSoC Creator, which allows you to configure, program, and debug their products (there is a very useful series of video series on using PSoC Creator).

The PSoC architecture sits somewhere between an MCU and an FPGA. In addition to the processor core, it has some configurable analog circuitry along with some programmable digital fabric, although this fabric is not as granular as one would find in an FPGA. You also get a whole bunch of IP with the device (termed "components") that allow you to configure the device to perform the functions you require. One aspect of the development environment is illustrated in Figure 1.

Figure 1. Starting to place the components(Click here to see a larger image.)

You need an ADC? Just choose it from the component selection area along the right and plonk it down. You want a PWM? There you go. An opamp and/or an SPI controller? You're welcome. Connect them together as you would on a schematic. Choose what pins to associate with the various functions, compile the hardware, and you are ready to write your application. Each component that you place has its code and headers placed in the "Workspace Explorer" (shown on the left in Figure 1) alongside your code. All the API calls are included in the header files and you can simply copy and paste into your code. You can see the symbol in the bottom right hand corner with the option to "Open Datasheet" (please forgive the eyestrain). Each component has its own data sheet that you can access before you place it, or by right-clicking after you've placed it.

PSoC Creator, which includes a Keil C compiler, is free. Support is also free. As an added bonus (here is my prejudice again), this system is not Eclipse-based. If you really want to be adventurous, you can create mini-state machines and other functions in hardware using a technique Cypress calls "datapaths." You can even use Verilog if you know what you are doing.

In my next column I will use my project to describe the design process in a little more detail. In the meantime, I welcome any questions or comments.

You know this could be just the thing to use for you BADASS display. I've got one of the pioneer kits at home that I've been meaning to do something with for a year. Maybe next month...

I've been busy getting antennas built and batteries charged for Field Day (http://www.arrl.org/field-day). Not to mention finding all the miscellaneous equipment and lengths of coax... Only 10 more days!

When is your next artical coming out and thanks for designing that reader controller at Debex all those years ago which was the foundation stone of my business that has lasted over 20 years.
Hedley Davidson

I've been waiting for a good reason to play with PSoC 4 (ARM Cortex-M0 core) and/or PSoC 5LP (Cortex-M3 core). I'm not interested in the 8-bit PSoCs. The PSoC 4 Pioneer board actually has both parts, because they use the PSoC 5LP as the download/debug device for the PSoC 4.

One thing I really like about the PSoC 5LP is that Cypress documents almost all the device registers, so you can program them directly instead of having to use PSoC Creator on a Windows PC. The thing I don't like is that "almost all" is not the same as "all". In particular, they don't document the routing resources so while you can program all those wonderful PLAs, data paths, interrupts, DMA, DAC/ADC, DSP, analog devices, etc., etc., you can't connect them together without using PSoC Creator. Now Creator is a fine tool and probably good for most users, but I find it's like using a video game and that's not the way I think about serious design. Also, I really dislike Windows (except for 2000) and pretty much only use it if somebody is paying me to do so.

So, I'm still waiting for Cypress to take that last little step to document the routing registers which is all that's needed to make PSoC the first programmable logic device (except for an obscure Atmel part that never caught on) that permits open source development. Since the PSoCs have all programming information inside the chip and you have the option to lock it all down, PSoC customers don't have to worry about reverse-engineering so IMO Cypress really doesn't have an excuse.

No fiddling with wirewrapping with the Cypress Psocs. Just draw lines on the screen to connect the analog and digital "parts" from the included library and draw lines to the desired output pins.

I wanted to reply to note that Cypress has a simple Verilog tutorial, that is a great quick read on how to program in verilog for the PSoc 4 using the Creator free software. Turns out not to be hard, at least this Verilog subset. And is a great inexpensive way to play with real Verilog without spending a lot of nickles.