interrupt handling

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
Anonymous
Not applicable
        How ISR work by setting the Flag?? unit32 Flag1 = 0; CY_ISR_PROTO(MyFunction); intmain() { SetHandler (MyFunction) ; } CY_ISR(MyFunction) { Flag1=1u; LIGHT Write(1); CyDelay(200); Flag1=0u; }   
0 Likes
4 Replies
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

At first: Never ever use a delay within an interrupt handler, this may stall the complete system.

   

I did not hear of a SetHandler() function, but for an interrupt component there is a isr_StartEx() API

   

You are setting and resetting the flag, nobody will see that.

   

You need an infinite loop in your main() or the program will halt or be re-initialized.

   

All global variables changed in an interrupt handler should be declared with "volatile" to prevent them from getting optimized out of a loop.

   

 

   

Bob

0 Likes
Anonymous
Not applicable
        How flag set & how main function call handler?   
0 Likes
lock attach
Attachments are accessible only for community members.
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

An interrupt is something asynchronous and is usually not "called" i.e. from main(). Instead an interrupt gets fired by an external event (a signal changing, a character received or a button pushed)

   

Attached: A script about interrupts

0 Likes
ETRO_SSN583
Level 9
Level 9
250 likes received 100 sign-ins 5 likes given

Some more ref material -

   

 

   

http://www.embedded.com/design/programming-languages-and-tools/4397803/Interrupts-short-and-simple--...

   

 

   

http://www.cypress.com/documentation/application-notes/an54460-psoc-3-and-psoc-5lp-interrupts     AN54460 - PSoC® 3, PSoC 4, and PSoC 5LP Interrupts

   

 

   

http://www.cypress.com/?rID=95069     AN90799 - PSoC® 4 Interrupts

   

 

   

http://www.barrgroup.com/Embedded-Systems/How-To/C-Volatile-Keyword    Volatile

   

 

   

Regards, Dana.

0 Likes