This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Writing to a Specific Program Memory Location in C for an ISR

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.

Parents
  • 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

Reply
  • 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

Children
  • 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.

    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.

  • 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.

    Erik