Guide” and Cypress AN77759 “Getting Started with PSoC
5LP,” and use them to get off to a quick and easy start.
(Directions are included with the article downloads.)
A Cypress 5LP PSoC (Programmable System-on-a-Chip) device includes many “building blocks” for functions
such as SPI, USB, and UART ports; EEPROM; clocks;
analog-to-digital converters (ADC); pulse-width modulators
(PWM); and so on.
Unlike other MCUs, the 5LP devices only implement
(or “connect”) the blocks you want. You select a function,
drag its block into the PSoC Creator schematic drawing
area, and set parameters.
In most cases, you don’t need to set bits in registers.
Each block has its own datasheet, and example programs
give you a head start. When you “build” a project, the
PSoC creates the APIs for you. The documentation for
each block lists the APIs and explains their uses.
Configure an SPI Port for 11
Figure 4 shows an SPI slave port as I configured it.
The MOSI (master-out, slave-in) pin connects to the
keyboard’s data-output signal. The keyboard clock
connects to the SPI serial-clock input (sclk). I connected
the slave-select input (ss) internally to a logic 0, so the SPI
Like many other PSoC components, the SPI port
requires an internal synchronizing clock. I chose a clock
from the list of blocks and set it for a 1 MHz output. The
documents mentioned earlier explain how to start a
project like this, configure blocks, assign physical I/O pins
to signals, and build a project with the PSoC Creator
software. (I connected the MOSI to a PSoC output pin,
but this project does not use it.)
A rapid double-click on the SPI slave block opens the
SPIS_1 Configure window shown in Figure 5. Here, you
select one of four modes, and as you examine each, the
timing diagram changes to illustrate the signals for that
mode. I chose the clock-phase (CPHA = 1) and the clock
polarity (CPOL = 1) that match the keyboard clock and
data signal levels and edges shown earlier (refer back to
The PSoC SPI block works with from three to as many
as 16 bits. I chose 11 bits to match the number of bits
transmitted by a keyboard. I also chose LSB first as the
shift direction for incoming data to match the keyboard’s
data format. This setting simplifies software for keyboard
The Advanced section of this window (Figure 6) lets
me select an external clock: the 1 MHz clock shown in
Figure 4. This clock signal is external to the SPI block and
used only within the PSoC to synchronize processor and
logic activities. I also chose an SPI buffer memory size for
four 11-bit values, and no interrupts. Anyone familiar with
peripheral setup in a typical MCU will appreciate the ease
of SPI setup.
That simplicity applies to other blocks, too.
You don’t search through lists of registers to find
a bit that enables a peripheral and then tinker
with other bits to get the behavior you want. The
PSoC Creator handles those details. The software
does the same things for a UART in this project.
The UART sends ASCII values to a terminal
emulator on my PC.
A separate window lets you assign the
signals to physical I/O pins. In this project, the
68 July/August 2018
FIGURE 3. A CY8CKIT-059 5LP prototyping kit. The four
contacts on the left mate with a female USB connector.
These signals communicate data and programs between
the PSoC chip and your host PC. Photo courtesy of Cypress
FIGURE 4. My SPI port in the PSoC Creator schematic window.
You drag and drop an SPI and other building blocks into the
schematic area as needed and connect them with "wires." Later,
you assign signals to physical I/O pins. I used the default name
SPIS_1 for this block, but you can change it as you wish.