← Previouos chapter | Table of Contents | Next chapter →
Chapter 3: Quick Start
From the free online book “Architecture and Programming of PSoC Microcontrollers”
Introduction
Every beginning is the hardest part of every job. Because of that, it is very important to write complete project that works, as soon as possible. What else could be in a microcontroller world than LED blinking? Basic idea is that we implement LED blinking by using PWM16 component, with the same signal/pause ratio. It is done in a very simple way, by selecting frequency of 32kHz with period set to 32000, and impulse to 16000, for base frequency of PWM16. User just should connect output of PWM component to output pin Port_1_0 to where is LED connected, and write simple code to start PWM component. All the steps are similar in more complex projects.
3.1 Creating a Project
Click on the New Project icon opens a New project Wizard, where user should specify name, and location of the project.

Left side of the window is used to choose the way that new project will be formed. Most common choice is to start new project by click on Create New Project icon. If there was a need to modify already existing project, or change of microcontroller type of some previous design, one of lower two choices should be selected.

Click on the Next, new window with assembler or C selection is opened. Option Assembler is available to all users, while for C one needs license. For this example, microcontroller CY8C27643 and Assembler should be selected.

Button Finish opens Device Editor window where user can select programmable components. Component PWM16 can be found in PWMs section. Importing it to the project is done simply, by marking its icon, and right-click selection. As a result of this operation, graphical simbol of PWM16 block will appear in selected components slot, automatically named as PWM16_1. This name can be changed by user.

Note that resource window shows that component PWM16 takes two digital blocks, which means that it is possible to place a maximum of three blocks like this. After component selection, we go to interconnection window by click on the icon Interconnect View.

Component placement in a marked free locations is simply done by right click on the component.

Next step is to adjust parameters of PWM16 component. Period and width of PWM impulse is set in window User Module Parameters. Parameter value of 32000 with input frequency CPU_32_KHz results in one second period. For equal length of signal and pause, Pulse Width is set to half of period, e.g. 16000. Final view of the User Module Parameter window is illustrated in the figure below.

PWM16 output signal CompareOut is connected to output pin P1[0] in three steps. As a first, since LED has been connected to pin Port_1_0, PWM16 output CompareOut should be connected to digital output line with index 0, in this case Row_0_Output_0. Click on this line opens output digital multiplexer settings, where should be done connection to a global output line by enabling appropriate buffer.

Since LED is placed on odd Port_1_0, it is necessary to make connection trough Odd buffer line GOO_0 as it was illustrated in a figure above.
Final link with output pin is accomplished by click on Global_OUTOdd_0 linije and selecting pin Port_1_0.

When component is placed, and connected to output pin user can start to write code. Before that, Generate Application icon should be clicked, which starts automatic generation of files for PWM16 component.

Application editor selection is done by appropriate icon click, which is shown in the figure below.
![]()
On the left side of Application Editor, list of all automatic generated files can be found. Click on file main.asm from Source Files section, opens the main program window. For PWM16 to start working, all necessary is to call Start procedure PWM16_1_Start. List of all other subprograms that could be used for given component is found by opening .asm file with the same name as the component in Library Source section, or in appropriate component manual. Click on pwm16_1.asm opens a window with all subprograms. All available subprograms from this file are declared with directive extern.

After code is written, compiling should be started by clicking on icon Build. In case when code does not contain any mistakes, compiling will be succesfully, and blink.hex file will be generated in the folder output.
![]()
