Cypress PSoC

As part of my robotics experiments, I decided to start working with microcontrollers. In mid-2006, I started experimenting with the Microchip PIC. I obtained a couple of PIC16F628 devices, set up gputils, gpsim, piklab, and sdcc. I even build a simple PIC programmer. By late-2006, I ran into the limitations of the device and the tools. At the time, sdcc for the PIC still had some problems generating code. I was rather reluctant to program in assembly language. I wanted to program at a higher level so I could make more efficient use of my time. I toyed with possibly using picforth, but I wasn't particularly excited about porting picforth to the 16F628.

In retrospect, I should have looked into using the AVR series of parts, as a port of gcc was readily available. Instead, I ran across an offer for a very inexpensive evaluation package for the Cypress Programmable System on Chip (PSoC). For US$10, I could get the evaluation board, a mini-evaluation board, two CY8C29466 PSoCs, a USB programmer, and development software (for MS Windows only). At that price, I couldn't resist. The deal was even better when I actually received two complete evaluation packages for my US$10. I sent myself on an interesting adventure.

The Cypress PSoC is a form of field programmable gate array (FPGA) coupled with an M8C microprocessor, supporting system resources, RAM, and flash EPROM. There is an array of programmable digital blocks and an array of programmable analog blocks. Generally, each digital block can be configured to be one of the following functions:
  • 8-Bit Counter
  • 8-Bit Timer
  • Buffer
  • Inverter
  • 8-Bit Pulse width modulator (PWM)
  • Dead-band generator
  • 8-Bit Asynchronous receiver
  • 8-Bit Asynchronous transmitter
  • 8-Bit Cyclic redundancy check (CRC) generator
  • 8-Bit Pseudo random sequence (PRS) generator
  • Serial peripheral interface (SPI) master
  • Serial peripheral interface (SPI) slave
Counter, timer, PWM, CRC, and PRS blocks can be cascaded with similar type to form 16-bit, 24-bit, or 32-bit functions. Most blocks can be configured to trigger interrupts under certain conditions. The number of available digital blocks depends upon the model or PSoC device. The CY8C29466 has four rows with four digital blocks in each row, or sixteen digital blocks total.

The analog blocks consist of continuous time (CT) and switched capacitor (SC) blocks. The CT blocks are essentially operational amplifiers that can be used to implements the following functions:
  • Comparator
  • Instrumentation Amplifier
  • Programmable Gain Amplifier (PGA)
  • Reference Muxtiplexer
The SC blocks can be used to implement the following functions:
  • Band-pass Filter
  • High-pass Filter
  • Low-pass Filter
  • General Switched Capacitor Block
  • Delta-sigma Analog-to-Digital Converter
  • Successive Approximation Analog-to-Digital Converter
  • Digital-to-Analog Converter
  • Multiplying Digital-to-Analog Converter
All analog blocks support high-frequency audio processing. The number of available analog blocks depends upon the model or PSoC device. The CY8C29466 has one row with four CT blocks and two rows with four SC blocks in each row, or twelve analog blocks total.

Most of the data pins on the PSoC can be configured as either inputs or outputs to digital or analog blocks, or as general purpose I/O pins controlled directly by the microprocessor. Each I/O pin can also be configured to trigger an interrupt.

The M8C microprocessor is a fairly simple and not particularly fast CPU. It possesses an 8-bit modified Harvard architecture and has an accumulator (A), index register (X), program counter (PC), stack pointer (SP), and flags register (F). The M8C is somewhat reminiscent of the MOS 6502, which I programmed many, many years ago. Depending upon the model, a PSoC can have between 256 and 2048 bytes of paged RAM and between 4 and 32 kilobytes of flash-programmable ROM. The CY8C29466 has 2048 bytes of RAM in eight, 256-byte pages and 32 kilobytes of ROM. The support functions that can be accessed by the microprocessor are:
  • Internal Main Oscillator (IMO)
  • Internal Low-Speed Oscillator (ILO)
  • External 32.768 kHz Crystal Oscillator
  • 8x8-Bit Multiply, 32-Bit Accumulator
  • Decimator Block (Type 1 or Type 2)
  • System Resets
  • I2C Master/Slave Block
  • Voltage Reference
  • Power On Reset (POR)
  • Low Voltage Detect (LVD)
  • Switch-Mode Pump
  • I/O Analog Multiplexers
  • USB 2.0 Slave Interface
The number of available resources depends upon the model or PSoC device. The CY8C29466 has all of the aforementioned resource except for the USB interface. It has two multiply/accumulators and a Type 2 decimator block.

The PSoC's digital and analog blocks are configured by the microprocessor by setting configuration registers. Consequently, the configurations can be changed dynamically, according to need. This enables the PSoC to be a very flexible device. In my opinion, the PSoC is an ideal microcontroller for the robotics experimenter. The pins of the PSoC can be allocated for different robotics functions, such as motor control, sensors, and communications. As needs require, the digital and analog blocks within the PSoC can be reconfigured and rerouted to the pins to support different functions. The PSoC can then support many more functions than would otherwise be possible. The CY8C29466 has only 28 pins and supports 24 pins for I/O. Its sister components,the CY8C29566, CY8C29666, and CY8C29866, support more I/O pins and would provide even more flexibility.

Currently, development software is supported much better in the Microsoft Windows environment than in the Linux environment. The PSoC Designer provides a powerful IDE to develop PSoC applications in assembler or C. Placement and interconnection of digital and analog blocks is performed in one screen. Programming is assembly or C language is performed in another window. Separate build processes are required for generating code for the block configuration and compiling and linking code.

The PSoC Explorer provides a high-level object-oriented design environment. Various object components can be plugged together and configured to create embedded applications. This spares the developer the need to learn assembly language or even C programming at the cost of lower performance and design flexibility. I quickly outgrew the capilibities of PSoC Explorer and switched to PSoC Desinger. It does have a steeper learning curve, as you have to come to an understanding of the inner workings of the PSoC.

In the Linux environment, only the m8cutils package is available. It consists of assembler, linker, and simulator tools that support the M8C microprocessor core. Designs for device programmers are also available. One of the interesting aspects of the simulator is that it can talk through the device programmer to the PSoC's In-System Serial Programmer (ISSP) and access the PSoC's registers. This allows the simulator to run the M8C assembly code as if it were actually running within the PSoC. I have not experimented with m8cutils yet, but I hope to do so in the future.

For development support, I highly recommend the PSoC Developer website. The data resources and user forum are top notch. The other users that frequent the forum are very helpful and knowledgeable.

Projects

As I have climbed the PSoC learning curve, I have developed some projects. Some of these projects are not necessarily robotics related, but they have helped me to learn the capabilities of the PSoC. I'll add new projects as I bring them to a publishable state. Note that the time that they appear is not always in the same order as when they were developed.

© 2008 Mac A. Cody

Last updated Saturday, July 12, 2008