Is there a place to store a pointer that I can pick up in an interrupt handler?

jmbldwn gravatar image

asked 2013-09-23 23:15:26 +0100

updated 2013-09-24 01:28:13 +0100

In my ADC interrupt service routine (ADC_IRQHandler), I'd like to have a pointer available that I could use to carry some state from the main app thread to the IRQ handler.

Yes, I could do this by declaring a global, but I go to great lengths to avoid using globals so if there's an existing place to stash a pointer I'd be much happier.

edit retag flag offensive close delete report spam

1 answer

Sort by » oldest newest most voted
JKelley gravatar image

answered 2013-09-23 23:23:43 +0100

updated 2013-09-24 01:28:13 +0100

Globals are the only answer unless you want to write a function to return a pointer to a static member variable and call that from your interrupt routine. For example:

struct my_struct *get_my_struct_ptr() { static struct my_struct data; return &data; }

edit flag offensive delete publish link more

I think that's a little cleaner than a global as it limits the contract to the function call vs. leaving a variable out there that is hard to change down the road. Thanks!

Jim ( 2013-09-24 01:28:08 +0100 )editconvert to answer

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer. Do not ask a new question or reply to an answer here.

[hide preview]

User menu

    or sign up

Recent questions

Question Tools


Asked: 2013-09-23 23:15:26 +0100

Seen: 2,242 times

Last updated: sep. 24 '13