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.

Can't pass parameters to functions called in ISRs

Just recently a project I have been working on for sometime gave up passing correct parameter values to functions called from ISRs. The values in the arguments are correct until the point the function is called then upon stepping into the function they change to different data. Data that appears random, yet is the same upon every iteration.... not overly sure why this happened, there was no major change to the code at the stage this changed. Anyway for the most part it has been easy enough to just inline the required functionality into the ISRs instead of calling functions, or call functions that take no arguments.

However I have one this just won't work for, calling the sig gen from the TI Sine Generator library. The SGENTI1 macro uses a function, SGENTI_1.calc(), that requires an argument of SGENTI_1 (a struct defined by the lib).

The ISR that call this function is an ASM ISR generated by a PWM trigger , as done for the TI DPLib. This in turn calls a little wrapper function that simply checks if the sig gen is enabled, then calls the sig gen handler, passing in the struct argument, as laid out in the TI documentation.

Can anyone tell me why my ISR called functions seem to have stopped accepting parameters correctly when they managed it previously? Thanks

(C2000, F28027, LaunchPad)

  • To clarify If I have some ISR 'my_isr()' that calls a function some_inner_func() with a parameter(s), the argument passed for parameter do not seem to be honored. That is, for e.g. if the argument is '5', when the function starts to actually execute the argument is actually read as something like 1028.

    uint16_t x = 5;
    
    static void some_inner_function (uint16_t y) {
        // When execution is here y should be equal to x.
        // But it is always equal to some constant, seemingly,
        // random number instead.
    }
    
    static void interrupt my_isr (void) {
        //...
        // Here x is equal to 5.
        some_inner_function(x);
        //...
    }

  • Hello Toby,

    Could it be that the debugger is not showing the correct information.

    Save one of the parameters that seems to be changing into a global variable.  Then check to see if the global variable has the correct value. 

    Stephen

  • I ended up just restarting my entire test rig systems (which I typically leave on for couple weeks or so) and it *seems* to have solved whatever was the issue.

    Ta