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.

Read Program Counter(PC) using UCD3138

I wnat to use C code to read PC, have any sample code or doucment to introduce it?

 

thanks.

  • Yang,

    I am curious why you are trying to read the program counter. What is it you are trying to do? Please let me know and I can help you from there. For your information however, in theory, the PC could be read by storing the PC to a memory location and then reading the value at that memory location.

    However, This would need to be done in Assembly. We do have instances in our C code where we make use of assembly instructions. For example in interrupts.c we have statements such as:

    asm(" MRS r4, cpsr "); // get psr

    However we do not have sample code for reading the program counter. We have never had reason to read the PC.

    Regards,

    Brandon Vonk