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.
I'm attempting to use the timer 1 ISR for the ADuC814. In assembly I easily use the ORG directive to write to the address that the PC jumps to when the interupt is set. How do I do the equivalent in C? Any help would be appreciated.
Alan,
You will no doubt receive a number of responses shortly prompting you to read the manuals for the C51 compiler thoroughly, and that will be good advice. That being said, here's some information:
You can locate any function to a specific location in code space by placing it in its own module and then telling the linker where to locate that module. It's a cumbersome and often unnecessary process, however.
In your case, Keil makes it easy to locate ISRs in the appropriate place by using the "interrupt" keyword. Each ISR has an interrupt "number" that really just represents the address where keil will place the entry point for that function. Search on the "interrupt" keyword in the manual and you'll quickly find out how to do what you're looking for.
-Jay Daniel
You're trying to write assembler programs in C!
A better question would be, "How do I write Interrupt Handlers in C51?" This question is answered in the C51 Manual:
http://www.keil.com/support/man/docs/c51/c51_le_interruptfuncs.htm
Note that locating the function at the correct CODE address is necessary but not sufficient to make it an interrupt handler...!
and would not work for an ISR (as this thread is about) writing an ISR as a function and linker locate it would make the compiler exit the function with 'ret' instead of 'reti'
Erik
PS do not fall for whatever "interrupt number" the datasheet for your derivative may state, for C purposes the interrupt number is (vector address -3)/8
"writing an ISR as a function and [forcing the] linker [to] locate it would make the compiler exit the function with 'ret' instead of 'reti'"
Yes - hence forcing the adress is necessary, but not sufficient.
Thanks for the help. This is my first time using keil and doing any embedded work. I've got the interupt functioning.
and would not work for an ISR (as this thread is about)
He also intimated that he knew how he would have used "ORG" in assembly to get something done and asked about the equivalent in C. In general, only the linker can implement ORG for you. In the special case of ISRs (which I very-well understand he's talking about), I pointed out the interrupt keyword.
not complaining about your post, just clarifying.
"This is my first time using keil..."
So now would be a good time to have a thorough read through the Manuals to ensure that there aren't any other important features & facilities that you're missing...
work through the examples in the "getting started guide". That is 517% better than just reading the guide.