Skip to content

Latest commit

 

History

59 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

PSoC 4 Learning Lab

Hands-on lessons and creative embedded projects for the Cypress/Infineon PSoC 4 and the CY8CKIT-042 PSoC 4 Pioneer Kit.

This repository began as a practical journey through the Cypress Academy: PSoC 101 tutorials. It then grew beyond the guided exercises into a collection of original training projects that combine programmable hardware, embedded C and external electronics.

Learn the blocks. Connect the blocks. Build what you imagine.

The lessons introduce one concept at a time. The projects show what happens when GPIO, interrupts, timers, PWM, ADC, CapSense, UART, I2C and SPI stop being isolated peripherals and become parts of a complete system. Once those building blocks are familiar, the practical limit is not the list of examples—it is what you decide to sense, communicate, illuminate or control.

Platform at a glance

Item Details
Development board CY8CKIT-042 PSoC 4 Pioneer Kit
Target device CY8C4245AXI-483
Processor Arm Cortex-M0
Development environment PSoC Creator
Workspace version PSoC Creator 4.2 (4.2.0.641)
Application language Embedded C
Design approach Graphical hardware schematic + generated component APIs + application firmware

The projects were designed and tested for the CY8CKIT-042. They may be adapted to another PSoC 4 kit, but the target device, component availability, electrical characteristics and pin assignments must be reviewed first.

Repository map

The repository offers two complementary routes:

  1. Guided lessons — learn the platform progressively, from a blinking LED to communication interfaces and low-power modes.
  2. Training projects — reuse several lessons at once to build interactive, measurement, display and motion-control applications.
Cypress-PSoC4/
├── Lesson1.cydsn ... Lesson17.cydsn
│   └── Progressive PSoC 101 exercises
├── TrainingProjects/
│   ├── ADC, PWM, UART and CapSense applications
│   ├── LED and 14-segment display control
│   └── Stepper-motor control in three stages
└── PSoC-101.cywrk

Guided learning path

There are 19 lesson projects: lessons 1–17 plus alternative versions of lessons 13 and 16. Several exercises deliberately move functionality from the CPU into the PSoC programmable fabric; an almost empty for(;;) loop can therefore be the intended result rather than missing code.

1. GPIO and event-driven firmware

Lesson Concept What it demonstrates
Lesson 1 Software output Toggles the onboard red LED from firmware: the embedded equivalent of “Hello, World”.
Lesson 2 Software input Reads switch SW2 and writes its state to the LED.
Lesson 3 Interrupts Replaces continuous polling with an ISR that toggles the LED when SW2 changes state.

2. Configurable digital hardware

Lesson Concept What it demonstrates
Lesson 4 Hardware pins Connects input and output behavior in the schematic instead of implementing it in the main loop.
Lesson 5 Toggle flip-flop Uses programmable digital logic to retain and toggle state.
Lesson 6 Basic counter Introduces hardware counting as a reusable building block.

These projects are an important PSoC lesson: not every behavior needs to be executed instruction by instruction by the Cortex-M0. Some data paths and state machines can be assembled directly in configurable hardware.

3. Counters, timers and PWM

Lesson Concept What it demonstrates
Lesson 7 Counter terminal count Counts three switch activations and toggles an LED from the terminal-count interrupt.
Lesson 8 Pulse-width modulation Sweeps the PWM compare value to vary an output duty cycle.
Lesson 9 Timer capture + PWM Experiments with translating captured timing into LED brightness. The source still retains a TODO for measuring the interval between switch events.

4. Serial communication

Lesson Concept What it demonstrates
Lesson 10 I2C receive Exposes a one-byte EzI2C buffer whose value controls PWM duty cycle.
Lesson 11 I2C transmit Publishes the current PWM counter value through EzI2C.
Lesson 12 UART Receives lowercase characters, converts them to uppercase and sends them back to the terminal.

5. CapSense and the hardware–firmware boundary

Lesson Concept What it demonstrates
Lesson 13 CapSense slider Reads the capacitive slider centroid and reports position changes through UART.
Lesson 13-b CapSense buttons Treats five CapSense regions as independent buttons and reports their events through UART.
Lesson 14 Status register Transfers status from the programmable logic into firmware and reports changes over UART.
Lesson 15 Control register Drives hardware selection from firmware by cycling a control value across four channels.

6. Power management

Lesson Concept What it demonstrates
Lesson 16 Sleep + timer wake-up Enters sleep and resumes after a timer interrupt. UART messages make the transition visible.
Lesson 16-b Sleep + GPIO wake-up Uses the onboard switch interrupt to change the sleep state.
Lesson 17 Deep sleep Places I2C in its low-power state, enters deep sleep and restores the component after wake-up.

Training projects

The TrainingProjects directory turns individual lessons into small systems. Each project can be studied as both an application and a starting point for a new design.

Project Blocks combined Result
KITT GPIO + timing Sequences four LEDs to create a Knight Rider-style scanning effect.
CapSense LED Patterns CapSense + UART + PWM + control register Selects different LED behaviors through capacitive buttons.
LED PWM Meter CapSense slider + four PWM channels Represents slider position as a four-LED bar with proportional brightness.
ADC–UART SAR ADC + interrupt + UART + window detection Samples an analog voltage, converts it to millivolts and reports it to a terminal. Tested with a potentiometer.
ADC–PWM–UART SAR ADC + UART + PWM Extends the ADC monitor by mapping measured voltage to PWM duty cycle.
Buttons–LEDs–UART GPIO interrupts + PWM + UART Models two vehicle doors: opening or closing a door fades its interior light and reports the event to a console.
RGB UART Control UART command parser + three PWM channels Controls the individual RGB channels or the complete color using text commands such as R124 and W255090030.
SPI LED Driver Test SPI + UART + CapSense + PWM + interrupts Drives a TLC5926 and a 14-segment display, maps characters and generates brightness and transition effects.
Stepper Motor Test GPIO sequencing + timing Runs a 28BYJ-48 motor through a ULN2003A using an eight-state half-step sequence.
Stepper Motor Control Stepper control + UART parser Accepts target position and speed from a terminal, then performs the requested movement sequentially.
Interrupt-driven Stepper Control UART + PWM timer interrupt + stepper control Moves motor stepping into an ISR so position and speed commands can be changed while the application continues running.

Two projects worth exploring in depth

Interrupt-driven stepper motor

The motor projects form their own incremental tutorial:

Fixed rotation demo
        ↓
UART position and speed control
        ↓
Interrupt-driven, updatable motion

This progression exposes a classic embedded-system design problem. The first controller blocks while completing a movement, so it cannot react promptly to a new command. The final version delegates individual motor steps to a timer/PWM interrupt and leaves the foreground loop available for UART input.

SPI-controlled 14-segment display

The display project is the broadest integration exercise in the repository. It:

  • sends 14-segment bit patterns to a TLC5926 LED driver over SPI;
  • translates digits, letters and symbols through a character table;
  • receives character commands over UART;
  • selects operating modes using CapSense buttons;
  • uses PWM events to control display brightness;
  • implements breathing, sawtooth, reverse-sawtooth and intermittent effects;
  • retains a TODO hook for future LIN-based control.

It illustrates the central idea of this collection: the same components introduced in small lessons can be recombined into a much richer application.

Getting started

Install PSoC Creator on Windows together with the programming/debugging drivers required by the CY8CKIT-042.

1. Clone the repository

git clone https://github.com/jagumiel/Cypress-PSoC4.git
cd Cypress-PSoC4

2. Open an individual project

Open the required .cyprj file in PSoC Creator. The root PSoC-101.cywrk is a historical workspace saved with PSoC Creator 4.2 and currently references only Lesson13-b; it is not an index of every project.

For example:

Lesson3.cydsn/Lesson3.cyprj
TrainingProjects/ADC-UART.cydsn/ADC-UART.cyprj
TrainingProjects/StepperMotorControl/StepperMotorControl-Interrupt.cydsn/StepperMotorControl-Interrupt.cyprj

3. Study the complete design

A PSoC Creator project is more than its main.c. Review:

  • TopDesign — hardware components and their connections;
  • Design Wide Resources (.cydwr) — pin assignments, clocks and device resources;
  • main.c and local headers — application logic and interrupt handlers;
  • component customizers — UART speed, PWM periods, interrupt sources and other parameters.

Do not edit Generated_Source manually; PSoC Creator regenerates it from the schematic and component configuration.

4. Build, program and observe

  1. Connect the CY8CKIT-042 over USB.
  2. Build the selected project.
  3. Program the PSoC 4 through the onboard KitProg.
  4. For UART projects, open the KitProg USB-UART interface with terminal settings that match the UART component.
  5. Compare the observable behavior with the schematic and firmware before modifying the design.

Hardware

The first lessons mainly use resources available on the Pioneer Kit. The integration projects require additional components.

Hardware Used by
CY8CKIT-042 Pioneer Kit and USB cable All projects
Jumper wires, LEDs and current-limiting resistors GPIO and LED experiments
Potentiometer or another safe analog source ADC projects
External RGB LED, if not using the onboard device RGB UART control
TLC5926 driver and compatible 14-segment display SPI LED-driver project
28BYJ-48 5 V stepper motor and ULN2003A driver board Stepper-motor projects
Suitable external supply with a common ground Motor and larger external loads

Never drive a motor or a high-current display directly from a PSoC GPIO. Check voltage levels, current limits, grounding and the external driver's datasheet before connecting hardware.

From lesson to invention

Try extending the existing projects:

  • replace the potentiometer with a light, pressure or temperature sensor;
  • add a framed UART protocol with validation and acknowledgements;
  • control the RGB LED or display from I2C instead of UART;
  • add acceleration and deceleration profiles to the stepper controller;
  • wake from deep sleep on a sensor threshold or CapSense event;
  • complete the planned LIN command path in the display project;
  • combine CapSense, ADC feedback and motor control into a closed-loop interface.

The repository is intentionally a launchpad. A blinking LED teaches an output, a switch teaches an input, and an interrupt teaches responsiveness—but combining them is where a PSoC design becomes your own.

Project status and compatibility

This is an educational and historical PSoC Creator collection rather than a single production-ready firmware package.

  • Projects are independent and do not share one unified build.
  • Designs target the CY8C4245AXI-483 on the CY8CKIT-042.
  • Newer PSoC Creator releases may request component or project updates.
  • Some exercises preserve comments, experiments and unfinished ideas from the learning process.
  • Generated sources, build logs and compiled output are currently present in parts of the repository.
  • Hardware behavior has not been revalidated across other PSoC 4 kits.

Acknowledgements

The guided exercises were developed while following the Cypress Academy: PSoC 101 video series. Thanks to Cypress Semiconductor—now part of Infineon—for making the original lessons concise, practical and easy to extend.

Some source files are adapted from Cypress example projects and retain their original copyright and license notices.

License

This repository currently has no top-level license. Until one is added, no general permission to copy, modify or redistribute the author's original code is granted. Third-party and vendor-derived files remain subject to their own notices and license terms.

About

Progressive PSoC 4 learning lab and project collection for the CY8CKIT-042, from GPIO, interrupts and PWM tutorials to CapSense, ADC, UART/SPI, displays and interrupt-driven motor control.

Topics

Resources

Stars

1 star

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages