Previouos chapter | Table of Contents | Next chapter

Chapter 2: PSoC Designer

From the free online book “Architecture and Programming of PSoC Microcontrollers”

Introduction

PSoC Designer is program package that leads user through all stages of developing project. Version discussed here will be 4.2, but this book will still remain competent in case of newer versions, because differences are shown only in addition of new programmable components and some minor improvements. The most important for user is is to get familiar with two main parts of PSoC Designer:

  • Device Editor
  • Application Editor

Beside these two, there is also a debugger part, but during the course of this book it is only mentioned as an option, because it demands additional hardware. Device editor consists of two windows. First one is for selection and is called User Module selection View. Other, is called Interconnection View. It is used for setting and connecting components and parameter adjustment. Transfering from one to the other part of the PSoC Designer is done easily by clicking appropriate icon. To open Interconnection View or User Module Select windows, Device Editor icon must be selected first. Lower image shows look of the programmable component choice window.

Selection view icon

[back to the top]

2.1 Programmable Component Selection

Most important part of the programmable component selection window is placed on the left side. Components sorted in several groups, like AD converters, amplifiers, analog communications, counters, etc. After group selection, necessary component for project should be selected with double-click, or right-click on select. In the case of successful selection, appropriate graphical symbol would be shown in selected components slot.

Device editor

The rest of the window offers some other useful information. Resource Meter shows how much space is left for new programmable blocks. For example, 16-bit counter takes two programmable blocks, so it is possible to place 4 counters like this one altogether. During selection of each of the components, in lower side of the window is opened detailed instruction, which gives information about block characteristics, usage and code example. User does not have to know by heart all details about the component he uses, because this part holds all necessary information.

Resource meter

[back to the top]

2.2 Interconnection View

Previously selected components are still unusable, until they are placed in digital or analog programmable blocks, and until appropriate parameters are set. This important part of work can be done in Interconnection View window. Central part of this window is graphical representation of programmable blocks and connection lines. In the case of microcontroller of CY8C27xxx series, eight digital and twelve analog programmable blocks can be used. In the place between blocks there are internal lines for interconnection, and global purpose input/output lines. Although this scheme looks complicated at first sight, you can be sure that it isn’t hard to master the way it is all connected. In some way it resembles PCB routing, but really much simpler.

Interconnect view

Global Parameters

On the upper left side can be found Global Resources window. It is used for general parameters selection.This method of setting is similar to configuration words on other microcontrollers, but with more versatility. Click on any of the parameters opens pull-down menu with given options.

Global resources

All global parameters have default values, which means that even without setting microcontroller will be able to work. For example supply voltage can be 5V or 3,3V, depending on selection in parameter Supply Voltage. If user does not make selection, Supply Voltage parameter would be set on it's default value of 5V. When higher frequency precision is necessary it is possible to add external oscillator on lower two pins of port 1, and choose external as option in mentioned parameter. Most important parameters for our examples are internal frequency prescaler values of V1, V2 and V3. Signals V1, V2 and V3 are used by various analog and digital programmable blocks. V1 signal frequency value can be derived by dividing system frequency of 24MHz with prescaler N1. V2 signal frequency value is aquired by dividng signal V1 with N2. Acquiring signal V3 is done in similar fashion, by dividing some signal with value in N3, with possibility to choose from several different signals the one that will be divided. CPU_Clock represents frequency value, based on who are processed instructions of microcontroller.

Component Parameters

Central window on the left side is designated as User Module Parameters. Peripherals in PSoC microcontroller are very flexible, so it is required to set the way of their operation. Typically this is done by selecting frequency of the signal, connecting it with some other blocks and internal connection lines. Also, component specific parameters can be set. Such parameters are component specific, and it will be more discussed in chapter 5. In the picture below example for setting up component PWM16 is represented. In this case frequency signal is VC2. Time interval of impulse and pause is 32000 and 16000, respectively, of chosen frequency signal. Obligatory part of parameter are signals that are entering, and exiting programmable components. This operation can also be done in graphical mode, clicking inputs and outputs on set component. Picture holds example of adjusting signal frequency on component PWM16. Click on black triangle, which represents signal input, enables selection of possible clock signals. Specific parameters like impulse and pause interval, enable and similar are not obligatory to be set in this window, but is however desired. At a later point, while writing program in Application Editor, there is possibility for changing these values by calling specific procedures.

Component paremeters

Pin Parameters

Lower left side holds pin parameter options. In order to protect external devices from unexpected signals, default pin state of PSoC microcontrollers is Analog Hi-Z, in which microcontroller cannot change pin states. Pin drive mode selection can be done graphically by selecting appropriate parameters in column Drive or software by setting appropriate registers.

Option select is used for choosing the way pins are driven. If selected option is StdCPU, then pin have standard input/output function, and is disconnected from programmable blocks. If pin is supposed to be connected to appropriate global lines over which is established connection with peripherals it is expected to be done by user. Easiest way to do it is graphical, as it will be explained in next section of the book.

Column Drive is used for pin drive mode settings. Options pull-up or pull-down activate internal resistors, which set default logic state of pin to ONE, or ZERO, respectively. This is of importance while working with devices like push-button switches, because they allow direct connection to PSoC microcontroller without need for external resistors. Pull-up or pull-down resistors must not be used on analog inputs, like input of AD convertor because they can have impact on input voltage level. In such case state of high impedance, marked with Hi-Z Analog, should be chosen.

Third column is used when in the case of pin interrupts. It is possible to to select interrupt on rising edge, falling edge or state change depending on previous readout. For example, one of efficient ways to measure signal interval could be allowing interrupt on rising edge of signal. In interrupt routine is then started a timer, and following that, is allowed interrupt on falling edge, where timer is stopped in interrupt routine.

Pin parameters

Placement

Free locations for setting programmable blocks are represented by grey rectangles. Clicking some of selected components, marks placement space in graphical part. In case that communication from selected block, and intended pin could not be established, next available location could be selected, using icon Next Allowed Placement. Component placement is done by selecting component, and then right-clicking on Place, or shorter, using icon Place. During the placement of analog and digital components, general rule applies, that components that are to be connected should be placed in adjacent blocks. Components of upper four digital blocks are more easily connected among themselves, than with components from lower four blocks. Similarly, it is easier to connect analog components that are placed inside of one column.

Clk select

Digital Components Interconnection

For start, the most important thing is to get to know the basic elements of programmable blocks. Digital blocks are grouped in two entireties of four blocks, as shown on picture.

Digital components

On the upper side of each row there are four input lines to digital blocks, marked in red, and from the lower side of each block are four output lines marked in blue. Digital blocks aren’t connected directly to output pins, but over multiplexer and global input or output lines. Global lines are marked in green. Second letter in name tells about direction of the line I - input, O - output. Last letter in name gives information if lines could be connected only to E - even or O - odd ports. For example, GIE represents global input line that can only be connected to ports with even index (i.e. Port 0, Port 2...).

Input mux

Global input lines are placed on  the left side, while global output lines are placed at the right side. Procedure of connection global lines to pins is very simple. When certain line is clicked on, a  external pin name, or interconnecting input and output global lines, is shown. Selecting option Pin, pins of ports with according index will be offered. For example, global line GIO4 can be connected only with fourth pin of odd number ports. Global lines are connected with digital lines from programmable components over the multiplexer.

GIO lines

Multiplexer has a function to choose one input signal that will be connected with his output. Graphically, it is represented with a small square. There are input and output multiplexers, depending on connecting input or output lines. Clicking on some of input lines of digital programmable blocks, opens window with possible choice of connection. Connectiong on global output lines is a little bit more complicated than in previous case. The selected output line is taken, which is routed to output buffers. On upper left side is positioned multiplexer, which can select optionally connecting shown input line. Connection to global lines is established by clicking on appropriate buffer, which is represented in shape of triangle.

Output mux

If this step is done correctly, buffer will be painted blue as well as line that goes out from it. As additional element there appears a possibility for implementing logic functions with adjacent lines. Selection of logical functions is done by clicking on small square, and by choosing one of the options, after which is shown appropriate symbol. All digital components have input for frequency. Frequency signal is marked with black triangle. With left-click menu with possible selection of signal frequencies is shown. Some of possibilities are 48MHz, 32kHz, V1, V2, V3, as well as signals from some of global lines, BC lines or adjacent blocks. There are two groups of common lines marked as BC1 and BC0. Beside frequency input, other input/output lines could be found, depending on component type.

Output logic

Component view

Analog Components Interconnection

Analog blocks are placed on lower side of the graphic part of the window. Four analog columns and several multiplexers can be noticed. In every of columns, upper block ACB is used for analog amplifiers realization, while lower two are used for AD and DA convertors. Routing  is done graphically, by connecting frequency signal, and input signal to the same analog column. Pins with analog input/output of ports 0 and 2 are shown on the left side, which could serve as analog inputs or outputs. Columns on far left or right side could be connected only to odd or even pins of port 0, respectively. With help of two additional multiplexers there could be connected two middle analog columns to any pin of port 0. Each of analog columns can have one output that leads to one of four pins of port 0. Connection is established by using buffer that resides on bottom of every column.

Analog components

[back to the top]

2.3 Application Editor

Application Editor is used for writing programs, which can be done using assembly or C. Application Editor itself, bears much resemblance to IDE-s of other standard 8-bit microcontrollers. Left side window holds list of files that are contained in current project. Most important file for users is called main.

Application editor

This is the place of user code start. Include files are generated automatically based on selected programmable blocks in Device Editor, clicking on icon Generate Application. For example, if set programmable blocks are adcinc12, pga, and lcd, PSoC Designer automatically generates files with data and subprograms for their usage. So in the case of AD conversion, programming is done as simply as calling subprogram with start instruction call ADCINC12_Start and result readout with call ADCINC12_GetSamples. File Boot.asm is should not be changed because it is automatically rewritten during each new configuration. Names of available subprograms in part Library Source are in file with according name. When process of programming is done, compiling is started by clicking icon Build. In case of succesful compiling there will be shown message in lower window 0 Errors. At the same time, in folder output of the current project, .hex file will be shown which can be programmed into microcontroller.

Application editor adc

[back to the top]

Previouos chapter | Table of Contents | Next chapter