Professional Documents
Culture Documents
Cached Operations
Execution from flash memory is improved by caching instructions (PSoC 5 only)
PSoC software
PSoC Designer is the first generation software IDE to design and debug and program the PSoC 1 devices. It introduced unique features including a library of pre-characterized analog and digital peripherals in a drag-and-drop design environment
PSoC Creator is the second generation software IDE to design debug and program the PSoC 3 and PSoC 5 devices. The program that allows the user to select, configure and connect existing circuits on the chip and the components which are the equivalent of peripherals on MCUs.
32-bit PWM GP Logic 16-bit PWM GP Logic UART #3 GP Logic UART #1 GP Logic UART #2
SPI Master
The PSoC Creator Start Page has a link that enables one to create a new project as shown in the figure above. Alternatively, a new project can also be created by going to File > New>Project.
Once the new project is created, a window appears like the one shown above. Select Empty PSoC 3 Design and Assign your project a name
Click on the expand button next to Advanced. For example CY8C3866 is the device included with the DVK1 board, select that device for this project.
PSoC Creator generates the associated directories and files needed for your project and opens into schematic view
2.Adding components
Adding a Clock Component
Drag the Clock component from the Component Catalog (System group)onto the schematic.
Add an Interrupt component from the Systems group in the Component Catalog. Connect its terminal to the interrupt terminal of the PWM_Timer component. Previously you set this terminal to generate a signal on terminal count. Rename this component to isr_PWM. LED_Pin Add another Digital Output Pin component from the Ports and Pins group to your design. Double click the pin component and change the Name to LED_Pin. This LED_Pin to be software controlled, so deselect the HW Connection setting on the Pins Type subtab. Add a Digital Input Pin component to your design, name it as Button_Pin Set the Initial State to High (1). When you press the button, the pin is grounded and the state goes low.
4.Assigning Pins
PSoC Creator to route the pins to match the connections available on the Development kit board Steps for assignment of Pins for blinking LED Application
1.Double click on the filename.cydwr (Cypress design-wide resources) file from the
Workspace Explorer. 2. Select the Pins tab at the bottom to show the pin configuration of the project. You will see a graphic of the CY8C3866(device number ) PSoC with a description of the I/O pins and routing results. 3. Select P1[5] for the PMW_Pin , P1[6] for the LED_Pin , and P1[2] for the Button_Pin.
5. Adding Firmware
PSoC Creator generates much of the code needed for this project. Open main.c by double clicking the main.c icon under Source Files folder in the Workspace Explorer.
#include <device.h> #include "timing.h void ToggleLed(void); void main() { InitTiming(); /* interrupt */ PWM_Timer_Start(); /* source of interrupt */ CYGlobalIntEnable /* macro */ for(;;) /* main loop - do forever */ { /* This section contains code to be executed every millisecond */ if(milliSecond) { milliSecond = 0U; } /* end of millisecond section */ /* This section contains code to be executed every tenth second */ if(tenthSecond) { tenthSecond = 0U; /* Toggle the LED if the button is NOT pressed. This will cause the LED to blink rapidly when the button is NOT pressed.*/ if(Button_Pin_Read()) /* read a 1 when button is NOT pressed */ { ToggleLed(); } } /* end of tenth second section */ /* This section contains code to be executed every second */ if(oneSecond) { oneSecond = 0U; /* Toggle the LED if the button IS pressed. This will cause the LED to blink slowly when the button IS pressed.*/ if(!Button_Pin_Read()) /* read a 0 when button IS pressed */ { ToggleLed(); } } /* end of onesecond section */ } /* end of do forever loop */ } /* end of main */
void ToggleLed(void) { /* Set the pin to the opposite of what is read from the pin. The pin value is always right-justified to the LS bits.*/ LED_Pin_Write(LED_Pin_Read() ^ 1U); } /* end of ToggleLed */
Select Execute Code from the Debug menu of PSoC Creator Executing code will build the project if any changes have been made to source files or any configuration.It will program the target device and will halt at the main label in main.c.