This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Compiler/TMS320F28379D: Possible to pass pointer to interrupt service routine?

Part Number: TMS320F28379D

Tool/software: TI C/C++ Compiler

Is there a way to pass a pointer to an ISR that's passed when the ISR is called?

I have a working solution.  Though, it would be nice to avoid global objects when using C++ classes and ISRs.

If not, is there a mechanism to request this feature?

Kindly,

Graham

  • Graham Reitz29 said:
    Is there a way to pass a pointer to an ISR that's passed when the ISR is called?

    Unfortunately, no.  Because an interrupt can occur at any time, there is no way to collect the arguments for it.

    Thanks and regards,

    -George

  • Thanks George.

    On some systems a void* pointer can be passed to an ISR. When the ISR is setup (in code) a register is populated with the user pointer. That address is passed to the ISR each time it's called. I'm fairly certain that the pointer cannot (typically) be changed at runtime.

    In fact, I could do something similar, although manually. An established pointer to an object can be stored in a known register prior to setting up the ISR. When the ISR is invoked it can then access that pointer via the register (hard coded), cast it, and make use of it. It seems like the TI tool chain could automate this.

    Kindly,
    Graham
  • Graham Reitz29 said:
    On some systems a void* pointer can be passed to an ISR. When the ISR is setup (in code) a register is populated with the user pointer. That address is passed to the ISR each time it's called. I'm fairly certain that the pointer cannot (typically) be changed at runtime.

    That requires support in HW which the C28x devices lack.

    Graham Reitz29 said:
    In fact, I could do something similar, although manually. An established pointer to an object can be stored in a known register prior to setting up the ISR. When the ISR is invoked it can then access that pointer via the register (hard coded), cast it, and make use of it. It seems like the TI tool chain could automate this.

    You can already do this, if you just substitute a global variable for the register.  That being the case, there is not much motivation to add such a feature to the compiler.

    Thanks and regards,

    -George