- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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....
- Labels:
-
PSoC 3
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Bob is right, don't use interrupt with switch input directly.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Use the glitch filter with a pin to effect an ISR on a pin.
http://www.cypress.com/search.cfm?q=GPIO+interrupts&sa.x=22&sa.y=18
Regards, Dana.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
Bob