This example helps to understand the configuration for the Key Interrupt and how to react to the same on the Cypress PSoC 4 Pioneer Kit.
Here is the Application schematics:
This examples uses and non-hardware connected pins, so the pin components inserted this needs to be disabled.
The input pin needs to be configured so that its able to have a internal Pull up enable to help in default value stabilization and an interrupt on Falling edge as pressing the button would set a Logical low on the input.
The specific configurations for the PinSW { Digital Input Pin [v1.90] } are shown below:
Similarly the output pin { Digital Output Pin [v1.90] } need to be configured as follows:
In the source code we need to have an Interrupt handler to receive the interrupt event. In this case we turn On the LED for 100ms.
The code for this example is as follows:
#include <project.h> // Interrupt Handler CY_ISR(isr_wakeup) { Pin_LED_Write(0); CyDelay(100); //Delay of 100ms using Cypress Lib Pin_LED_Write(1); Pin_SW_ClearInterrupt(); // Clear the Interrupt just in case } int main() { Pin_LED_Write(1); //Switch off the LED initially // Configure the Key ISR handler isr_WakeUp_StartEx(isr_wakeup); CyGlobalIntEnable; //Enable Interrupts while(1); }
After building and programming this the Red color in the RGB Led would glow momentarily after the User button is pressed.
There is not glitch filter or de-bounce added in this design so there might be cases where there would be erroneous blinks.