Jump to content

How do you send variables to intrerupt function handlers?

Recommended Posts

Hello Everyone,


I have a very annoying issue that it seems i am not able to solve.


Following the timer example from boards directory from stellarisware, I can't figure it out how to send variables to intrerupt functions handlers like the

void Timer0IntHandler(void).



Using  a static variable inside void main() solves nothing; The thing is that these handlers are used as non called functions, meaning that when the intrerupt occurs

they will do their job. In my case I need to pass a variable to them, a variable that in the end will set up a MCU's pin.


Thank you in advance for the answer and example.




Link to post
Share on other sites

Make the variable scope wide enough to include the interrupt function.  static global or global.  Make it volatile.


Make the interrupt handler a dummy function that passes the variables to another sub-function.  This still requires that the int handler have visibility to the variables in  question.

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...