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.

Is it possible to read the PC (Program Counter) ?

I use 6455 DSP and want to just read (and not modify) the program counter.  I tried the following:

#include <c6x.h>
...
unsigned int temp;
temp = PCE1;

....

Is this the right way to do it?  I don't get the exact value of PC at the line.  It is slightly off.   Thanks

Bharat Meshwani

  • Bharat,

    PCE1 looks like a good way to do this. Why do you need more precision that what you get now.

    This is like looking at your watch to see the time in seconds or milliseconds, then you write down the time on a piece of paper, and by the time you finish writing the time has changed already. With PCE1, the processor will access the register, then copy it to a user register, then copy it to a memory location, and that may explain why you get a different result than what you expect.

    Regards,
    RandyP

     

    If you need more help, please reply back. If this answers the question, please click  Verify Answer  , below.

  • Hi Randy,

    What you write makes complete sense.  I wanted to read and log the PC to see where the program crashed.  Obviously one of the many ways to do this but this is a easy way.  Thanks for your help.

    regards

    Bharat