In this project, we'll build an application using the CY8CKIT-050 PSoC 5LP development kit to implement a countdown timer. The timer will handle countdown operations and display the remaining time on a 7-segment display. The countdown duration will be selected using dip switches, and the TIMER will handle interruptions for accurate time management. This experiment will help you understand how to configure and use the TIMER component in PSoC Creator for real-time applications.
PSoC schematic diagram
The timer project needs the following parts:
PSoC 5LP development kit
7-segment display
Dip switches for selecting countdown durations
Necessary wiring
Project Creation:
Open PSoC Creator.
Go to File > New > Project.
Choose the target device: PSoC5LP CY8CKIT-050 (CY8C5868AXI-LP035 chip).
Select "Empty Schematic" and name the project "Timer_Countdown".
Hardware Configuration:
Go to the Component Catalog on the right side of the screen, search for the following components and drag them to the TopDesign schematic:
Timer
Digital Input Pin (for button)
7-Segment Display
Arrange the components to represent the Timer control logic and display setup.
3. Component Configuration:
Double-click on the Digital Input Pin, rename it to "START_BUTTON", and set the drive mode to Resistive Pull Up.
Double-click on the Timer component, set the timer period according to the desired countdown duration (e.g., 1 minute = 60,000 ms for a 1-second tick), and configure it to generate an interrupt on overflow.
Configure the 7-Segment Display to handle four digits, suitable for displaying minutes and seconds.
In the workspace explorer, double-click on Pins under Timer_Countdown.cydwr and set Port to:
P2[0] for the 7-segment display common anode control (for example)
P3[0-7] for the 7-segment display segments (A-G and DP)
P1[0] for "START_BUTTON"
4. Programming and Results:
Double-click on main.c in the workspace explorer under source files.
Add the code to initialize the Timer, handle countdown logic in the Timer interrupt, and update the 7-segment display.
Build the design by clicking on "Build" or pressing Shift+F6.
Verify and resolve any warnings or errors.
Connect the PSoC 5LP to your computer using the USB cable.
Click on "Program" or press Ctrl+F5 to upload the code to the PSoC.
Test the Timer by pressing the button to start the countdown and observing the time displayed on the 7-segment display.
Verify that the Timer correctly counts down to zero, handling interruptions and displaying the correct remaining time.
Code for main.c
PSoC real-life implementation