Cypress Perform

Home > Design Support > Cypress Developer CommunityTM > Cypress Forums > PSoC® 3 > Regarding interrupts of psoc3

Bookmark and Share
Cypress Developer CommunityTM
Forums | Videos | Blogs | Training | Rewards Program | Community Components



Regarding interrupts of psoc3
Moderator:
RKRM

Post Reply
Follow this topic



Regarding interrupts of psoc3

sivananda posted on 25 Sep 2012 1:35 AM PST
Top Contributor
58 Forum Posts

hi...........

                      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....




Re: Regarding interrupts of psoc3

srim posted on 25 Sep 2012 02:40 AM PST
Cypress Employee
121 Forum Posts

 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` */

 

CY_ISR(isr_1_Interrupt)

{

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

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

    Timer_1_ReadStatusRegister();    

    /* 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:

 

CY_ISR(my_interrupt_routine)

{

// interrupt handle code

}

 

main()

{

CYGlobalIntEnable;

ISR_1_StartEx(my_interrupt_routine);

}

 

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.

 

Thanks,

srim

 

 



Re: Regarding interrupts of psoc3

srim posted on 25 Sep 2012 02:47 AM PST
Cypress Employee
121 Forum Posts

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



Re: Regarding interrupts of psoc3

H L posted on 25 Sep 2012 02:52 AM PST
Top Contributor
679 Forum Posts

 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. 



Re: Regarding interrupts of psoc3

Bob Marlowe posted on 25 Sep 2012 03:08 AM PST
Top Contributor
1768 Forum Posts

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

and

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..

 

Bob

 



Re: Regarding interrupts of psoc3

Bob Marlowe posted on 25 Sep 2012 03:10 AM PST
Top Contributor
1768 Forum Posts

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.

 

Bob



Re: Regarding interrupts of psoc3

H L posted on 25 Sep 2012 05:55 AM PST
Top Contributor
679 Forum Posts

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



Re: Regarding interrupts of psoc3

danaaknight posted on 25 Sep 2012 06:09 AM PST
Top Contributor
1773 Forum Posts

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

 

http://www.cypress.com/?docID=38930

 

Regards, Dana.



Re: Regarding interrupts of psoc3

H L posted on 25 Sep 2012 06:15 AM PST
Top Contributor
679 Forum Posts

This one as well. 

 http://www.cypress.com/?rID=2674

 






ALL CONTENT AND MATERIALS ON THIS SITE ARE PROVIDED "AS IS". CYPRESS SEMICONDUCTOR AND ITS RESPECTIVE SUPPLIERS MAKE NO REPRESENTATIONS ABOUT THE SUITABILITY OF THESE MATERIALS FOR ANY PURPOSE AND DISCLAIM ALL WARRANTIES AND CONDITIONS WITH REGARD TO THESE MATERIALS, INCLUDING BUT NOT LIMITED TO, ALL IMPLIED WARRANTIES AND CONDITIONS OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT OF ANY THIRD PARTY INTELLECTUAL PROPERTY RIGHT. NO LICENSE, EITHER EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, IS GRANTED BY CYPRESS SEMICONDUCTOR. USE OF THE INFORMATION ON THIS SITE MAY REQUIRE A LICENSE FROM A THIRD PARTY, OR A LICENSE FROM CYPRESS SEMICONDUCTOR.

Content on this site may contain or be subject to specific guidelines or limitations on use. All postings and use of the content on this site are subject to the Terms and Conditions of the site; third parties using this content agree to abide by any limitations or guidelines and to comply with the Terms and Conditions of this site. Cypress Semiconductor and its suppliers reserve the right to make corrections, deletions, modifications, enhancements, improvements and other changes to the content and materials, its products, programs and services at any time or to move or discontinue any content, products, programs, or services without notice.

Spec No: None; Sunset Owner: GRAA; Secondary Owner: RAIK; Sunset Date: 01/01/20