10 Replies Latest reply on Mar 4, 2014 3:01 AM by JoMe_264151

    Regarding interrupts of psoc3



                            while iam trying to implement PICU interrupt project from AN54460 application note of cypress....iam unable to make user defined function as ISR..instead, a default ISR is generating by my PSOC creator 2.0....Here iam mentioning the steps what i followed......please notice it....
                           1) I had taken two digital input pins for switches, which are again connected to two Interrupt pins.
                           2) Two digital output pins for two LEDS
                           3) Interrupt type parameter for both interrupts isr_1 and isr_2 is configured as DERIVED
                           4) isr_1 assigned a higher priority than isr_2
                           5) when i go to  'Build > Generate application" a default ISRs for two interrupts are generating, just same to that of "MY FIRST INTERRUPT PROJECT" from the same application note.....an i coudnt find "InterruptRoutines.h" file on source files
                   and at the end of document it is mentioned that the AN54460.cywrk workspace contains four code examples to demonstrate the topis of this application note.....can you please help me, how to open it....and from where i can retrieve this....

        • 1. Re: Regarding interrupts of psoc3

           Hi sivananda,




          There is an auto generated ISR_1.c file generated in A_MyFirstInterruptProject where the follwoing interrupt handler code is written.






          *  Place your includes, defines and code here 




          /* `#START isr_1_intc` */


          #include <Timer_1.h>


          /* Global variable definition */


          volatile uint8 toggle_flag = 0;


          /* `#END` */










              /*  Place your Interrupt code here. */    /* `#START isr_1_Interrupt` */    


              /* Read the timer status register to   clear the interrupt */ 




              /* Set the flag variable */


              toggle_flag = 1;


              /* `#END` */   










          This the space made available to handle code.




          Instead, there is an alternate way doin this.You can define the function in the source code files which is done in the second example proj in appnote (B_PicuInterruptProject). Use the following lines in main.c files to acheive this:








          // interrupt handle code


















          The isr.c and .h files are generated for every interrupt that you use. To avoid using these generated files, use the above lines of code to do it in the source files.


          Hope this helps.







          • 2. Re: Regarding interrupts of psoc3

             All the four projects are present in the same workspace (see image attached) of the appnote

            • 3. Re: Regarding interrupts of psoc3

               if you want to use your own interrupts (isr_1 and isr_2), you can go to the configuration of the pin and in under the input tab, slect interrup to none. 

              • 4. Re: Regarding interrupts of psoc3

                I cannot recommend this way of using interrupts, because when switching from PSoC3 to PSoC5 (or later 4) it breaks code.


                Instead I recommend to declare your own interrupt functions


                CY_ISR_PROTO(MyIntFunc); // Prototype declaration




                CY_ISR(MyIntFunc) // Interrupt function definition




                // Code goes here






                and in the initialization part of the program




                isr_StartEX(MyIntFunc); // Start Interrupt with my handler




                This suggestion will prevent you from funneling around in generated code, keeping everything together in your own files.


                For the CY_ISR-macro have a look into the "System Reference Guide" under Help -> Documentation..





                • 5. Re: Regarding interrupts of psoc3

                  By the way, I remember to have read not to connect interrupts to external pins when they are acted with mechanical switches, so take care for that and if appropriate use a debouncing algorithm.





                  • 6. Re: Regarding interrupts of psoc3

                     Bob is right, don't use interrupt with switch input directly.

                    • 7. Re: Regarding interrupts of psoc3

                      Use the glitch filter with a pin to effect an ISR on a pin.








                      Regards, Dana.

                      • 8. Re: Regarding interrupts of psoc3

                        This one as well. 






                        • 9. Re: Regarding interrupts of psoc3

                          Bob Marlowe - thank you for the suggestion. I too prefer your approach because I can write my ISR routines in main.c and avoid external declaration of variables and keep track of them in both files...No I can keep all in one source file.

                          • 10. Re: Regarding interrupts of psoc3

                            Additionally there is a path in the Workspace Explorer named "Generated_Source" which I delete from time-to-time. You cannot do that if you modified any of the files inside which I strongly avoid to do.