PSoC Interruptus
PSoC Creator has a novel yet effective way of incorporating ISRs (Interrupt Service Routines) where you can deploy ISR schematic components on the areas where you want an interrupt.
This is very quick and much simpler than some other IDEs and compilers that require you to define your own #pragmas and interrupt structures.
For instance, if you want a ISR for a rising edge for on a digital input just;
- Connect the ISR component onto the Digital Input on the Schematic Diagram
- Configure the ISR type - Derived, Rising Edge or Level
(There's no Falling Edge option so you can convert add an logical NOT component to change its sense.)
And voila!
A newly created ISR source code structure for the interrupt has been created in a .c file with the same name as its assigned component designator.
Edit this between designated #START and #END comments as required. It is very important to constrain your ISR code within the #START and #END comments to ensure that they are not overwritten with a project clean and rebuild.
My first Interrupt Test was done using the SW2 push button(P0.7) and the Red LED (P1.6)
The ISR merely toggled the state of the LED using;
To use this ISR you'll also need to;
Initialise it in your main.c using a call to isr_1_Start().
uncomment or insert the CyGlobalIntEnable statement.
The SW2 input pin was configured as a pull up to match the configuration of the SW2 button pin pulling the signal low.
The logical NOT component allows the resultant rising edge to be detected for the interrupt.
You can tune up interrupt priorities and other stuff as desired.
Notes:
1. The Debouncer component and associated clock is used to remove the unwanted switch bounce signals.
2. This article's video must be one of the world's most futile videos but it does prove that the code works.