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.

LAUNCHXL-F280039C: Reading of program counter

Part Number: LAUNCHXL-F280039C

Hi,

I'm working on the hard fault handler and I need to read and store some registers values.

Please provide the assembly code that let me read the program counter.

Thanks,

Dekel

  • Hello Dekel,

    The instruction "MOV XARn, PC" can be used to move the program counter value into a register (from XAR0 to XAR7). This can be found in the TMS320C28x CPU and Instruction Set Reference Guide.

    Best regards,

    Omer Amir

  • Hi Omer,

    Thanks for your response.

    I'm running the code below but it doesn't work.

    Please advise how to implement it correctly.

    Regards,

    Dekel

    C code:

    uint32_t pc = _getPC();

    ASM code:

    ;;*****************************************************************************
    ;; Get Program Counter
    ;;*****************************************************************************
    _getPC:
                 MOV XAR5, PC
                 POP XAR5
                 LRETR

  • Hello Dekel,

    Why are you popping XAR5? This will overwrite the XAR5 register with the data the stack pointer is currently pointing to (pop from the stack), thus erasing your PC value. If you change this to PUSH, what value do you see?

    Best regards,

    Omer Amir