We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
hello everyone,
how to write an interrupt service routine in c++
i have following class:
class nm { public: char i; };
& ISR is:
void timer_isr(void) interrupt 1 { nm.i = 10; }
if i write in this manner then i is not accessible as timer_isr is not a function of class nm
in c we dont declare interrupt function
shall i declare here? if yes then how?
pls guide me on this
thank you all take care
With Keils C51 compiler?
The answer is simple: You don't. C51 is a C compiler, not a C++ compiler.
it is not a C++ compiler!
See: http://www.keil.com/support/man/docs/c51/c51_intro.htm
And: http://www.keil.com/support/man/docs/c51/c51_xa.htm
thanks for reply, i m asking in general. i m using ceibo embedded developer in that i m writing code in c++ i m stuck in interrupt routine so i m asking for c++ code used for microcontroller
thank you take care
There is no "general" answer - such things are always specific to the particular compiler!
If there was a "general" answer, then you would find it in the language spec and general textbooks!
For some general books, see: http://www.keil.com/books
"i'm using ceibo embedded developer"
Then you need to direct your questions to Ceibo!
"in that i m writing code in c++"
Any particular reason why? 'C' is still by far the more common for small embedded development; especially for 8-bitters!
"in c we dont declare interrupt function"
Again, 'C' has nothing to do with it; the standard 'C' language knows nothing at all about interrupts - therefore, how you do this is entirely dependent on the specific compiler that you are using.
I know if at least one compiler where you do have to declare interrupt functions!