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.

CCS/TMS320F280049: How to read RPC?

Part Number: TMS320F280049

Tool/software: Code Composer Studio

My customer asked:

I’d like to read runtime RPC register (return program counter) when a watchdog interrupt is raised and store it in a not-volatile memory before executing the corresponding reset. Is there a way to perform this?

  • Hi Frank,

    This should be do-able but I believe will require assembly. You can push the RPC onto the stack from the watchdog function, and then there are a number of assembly instructions which can manipulate the stack to get it into a register accessible by C or directly into flash.

    You can use inline assembly instructions within your C code, for example

    asm(" PUSH RPC");

    You can view the full assembly instruction set here:

    www.ti.com/.../spru430f.pdf

    Regards,
    Kris
  • Frank,

    As Kris says, this can be done through a short assembly function. This would do it:

    ; assembly stub to get RPC

    .global _getRPC

    _getRPC:
    PUSH   RPC
    POP     ACC
    LRETR

    Place this in an assembly file and add it to your project. You would then just "extern" the function in your C code, something like this:
    extern unsigned int getRPC(void);

    Please post back if you run into any issues.

    Regards,

    Richard

  • Frank,

    Sorry, I realise I answered the RPC part of your question, but not the non-volatile storage part.  Writing a small amount of data into internal flash is not so simple on C2000.  There are a few details via this Wiki page:

    I'l ask around to see if someone has more up-to-date information for your device.

    Regards,

    Richard