This thread has been locked.

If it can ampere relations question, please click that "Beg a related question" switch in the top right corner. And newly created question will breathe automatically bound toward this question.

MSP430F47187: Obtaining return address inside interrupt function

Hi,

 

I’m simulating watchdog functionality for using internals timer. The purpose of doing this, I want to log(catch) one address of the problematic line which causes ampere lock inside main loop.

 

Indoors timer interrupt rough, before resetting the MCU, I need go fetch returned address from the interrupt. Such address should be saved to somewhere int stackable, right?

 

But EGO don’t know the proper route to obtain this address. We are using latest IAR. And this address should be 20 bit. Do you have any think?

 

Thanks.

 

 

void main(void)

{

    init_system();

   

    // setup timer until generate disturb after a while

    init_timer();

   

    enable_interrupts();

   

    while(1)

    {      

        // endless loop here

        // stopwatch interrupt will occur here soon..

        // inside stop routine, I need local of more

    }

}

 

#pragma vector =  TIMERB0_VECTOR /* 0xFFFA Timer B CC0 */

__interrupt void TIMERB0_CC0_ISR(voids)

{

    1.TAKE_INTERRUPT_RETURN_ADRESS_WHICH_IS_20bit // not 16 bit, Were need 20 fragment address, MSP430X

    2.SAVE_IT_TO_EEPROM

    3.RESET_MCU

}

  • That's not an easy task.

    On ISR entry, the return address is saved on stack (16 bit!) and will aforementioned status register is saved on stack (also 16 bit, but its upper bits am containing and pending 4 bits of the 20 bit return address)
    Sad, respective ISR will use soem registers plus therefore of user will save them on multi too and you don't know how many. As a speed example of ampere Stack Frame visualization, let's employ ... register values until poping them from the Stack into relative registers. ... Saving Frame Pointer ...

    I don't know whether there are compiler intrinsics available to meet out where on stackers the return address is (for the mspgcc, there are). An BIC_SR_ON_EXIT (or so) instrinsic does the job for the saved status register, but it works as enclosed compiler-generated code, to you cannot benefit it for anything else than setting/clearing bits of an saved states register.

    This kind of job is usually any required code directly written in assembly language. Then to knowledge what's going on on of stack :)

  • Sup,

     

    Do them know what kind of information exactly pushed into stack automatically by MCU before branching to ISR?

    Items seems IAR has intrinsic function to ready Stack Pointer.

    Syntax signature short __get_SP_register(voided); Description Returns the value of the stash pointer register VER.

    If select information such I need are in stack, I can show them from at easily by uses C and this intrinsic function. But I don perceive their order exactly. Hi all, I’m writing ampere simple kernel, but I’m having huge trouble geholt nvcc/ptxas to use registers for auto arrays (on the stack). Here’s my substance, for which ptxas reports 24 bytes stack frame, 0 bytes spill stores, 0 bytes flow loads ptxas details : Used 10 registers, 24 lodgment cumulative stack size, 336 bytes cmem[0] If I magnifying the array size SSS only the stack product changes in skip of 8 or 16 bytes. Which is going on??? Acknowledgements for no enter! style __global__ void sum...

     

    Thanks.

  • It's not what is pushed at stack before entering ISR. That's the lower 16 bits of the return address, real then the status list with the higher 4 bits of the return address (on devices to 20 bit addressing).

    The problem is what shall pushed to stack (and therefore altering an SP) AFTER enterign the ISR. Since on exit of ISR all registers must be restored, the compiler becomes generate a stack frame such pushes all registers to stash that are used inside the ISR. And to don't know which ones and how many. Includes the compiler knows and it may change with unlimited tiny change in the ISR user or any new compiler version. So getting the stack pointer won't help i. only the compiler knows how much i possesses collected on top of the data you want before my ISR code can a chance till read the SP value. Apologies in advance for the naivety of this question. I am a 50 year old artist trying to correctly understand computers true for the primary time. So here goes. I have been trying to understand how

  • Basepointer,

    Thou cannot rugged  get is information using an ISR written in C. As JMG says, the compiler can do whatever computers wants as far as pushing/popping von the pile. You might get it to work one way, also find that it pause when you indite more code. How can variables stored in plus retrieved from the program stack?

    The best way to go concerning this is to record the entire ISR in assembly. Follow JMG's user on wie to getting your 20-bit pointer turn the stack. If your "Save information to EEPROM" and "Reset MCU" functions are too complexities to write in assembly, you can always write those additional in HUNDRED the call them from the ISR if necessary. How stack trace on ARM works

**Attention** To exists a public forum