PSoC™ 6S2 GPIO-HAL LED Blink Lab
Lab 107
GPIO-HAL LED Blink Lab
Lab Objective:
The objective of this lab is to familiarize students with the basic concepts of GPIO (General Purpose Input Output) using a PSoC 6 microcontroller from Cypress (CY8CKIT-062S2-43012 Infineon Board). By the end of this lab, students should be able to initialize GPIOs, manipulate GPIO states, and create basic delay functions.
Lab Description:
In this lab, students will be tasked with programming a PSoC 6 microcontroller to control an LED through a GPIO. The LED will be made to blink at a regular interval, demonstrating basic GPIO output functionality.
The code will:
Initialize the board and all necessary peripherals.
Initialize a GPIO pin (connected to the LED) as an output.
Create an infinite loop where it:
Drives the LED GPIO pin low, turning the LED on.
Waits for 250 milliseconds.
Drives the LED GPIO pin high, turning the LED off.
Waits for another 250 milliseconds. This sequence will result in the LED blinking on and off every 250 milliseconds.
🔥 Requirements
Resources | Links |
---|---|
Computer | 💻 |
ModusToolbox™ software v3.0 or later | |
CY8CKIT-062S2-43012 Infineon Board | |
Technical Report |
🚩 Let start
Create Application
👉 Open Eclipse IDE ModusToolbox
👉 Select Board
👉 Select Application
Coding
👉 Add Code to the main() in main.c file:
for (;;) { ... }
: This is an infinite loop. Everything within this loop will be repeated indefinitely. This is common in embedded systems where the program is meant to run until the device is powered off.cyhal_gpio_write(CYBSP_USER_LED, 0);
: This sets the state of the CYBSP_USER_LED GPIO pin to low (0 volts), which typically turns the LED on.cyhal_system_delay_ms(250);
: This waits for 250 milliseconds.cyhal_gpio_write(CYBSP_USER_LED, 1);
: This sets the state of the CYBSP_USER_LED GPIO pin to high (usually 3.3 or 5 volts, depending on the microcontroller), which typically turns the LED off.cyhal_system_delay_ms(250);
: This waits for another 250 milliseconds.
This sequence makes the LED blink - it will be on for a quarter of a second, then off for a quarter of a second, continuously.
Build the Application
👉 Build Application
Launching the Application
👉 Launching Program
Before launching the program to the board, make sure that you have already connected the board to the computer through a USB cable.
Launching Program
👉 Check the Result
🎉 Congratulations! You can now complete Lab101
Supported toolchains (make variable 'TOOLCHAIN')
GNU Arm® embedded compiler v10.3.1 (
GCC_ARM
) - Default value ofTOOLCHAIN
Arm® compiler v6.16 (
ARM
)IAR C/C++ compiler v9.30.1 (
IAR
)
Supported kits (make variable 'TARGET')
PSoC™ 62S2 Wi-Fi Bluetooth® pioneer kit (
CY8CKIT-062S2-43012
)PSoC™ 62S1 Wi-Fi Bluetooth® pioneer kit (
CYW9P62S1-43438EVB-01
)PSoC™ 62S1 Wi-Fi Bluetooth® pioneer kit (
CYW9P62S1-43012EVB-01
)PSoC™ 62S3 Wi-Fi Bluetooth® prototyping kit (
CY8CPROTO-062S3-4343W
)
Related resources
Resources | Links |
---|---|
ModusToolbox™ Software Training |
Other resources
Infineon provides a wealth of data at www.infineon.com to help you select the right device, and quickly and effectively integrate it into your design.
Document history
Document title: BILL_MTB-101 – GPIO LED Blink Template
Version | Description of change |
---|---|
1.0.0 | Lab101: Introduction to GPIO control with PSoC 6, featuring an LED blinking . |
Authors:
Assoc. Prof. Wiroon Sriborrirux
Mr. Sriengchhun Chheang
Mr. Sabol Socare
© BDH Corporation, 2022-2023
Last updated