This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Set program counter

Hi,
how can i set program counter from variable in C code?

void func(void)
{
  uint32_t XADDR;
  XADDR = __current_pc();
  ...
  // need set PC from XADDR
  // msr pc, XADDR not compiled
}

Thanks in advance

Parents
  • You cant set PC directly. like PC = hhhh or so.
    But, you can modify the PC contents in C by using go to. You have to assign a label to the address (where you want to jump) and then go to that label.
    Alternatively, if you want only to call function(s), then function pointer can be used.

    But in any case you are not allowed this in C - PC = hhhh

Reply
  • You cant set PC directly. like PC = hhhh or so.
    But, you can modify the PC contents in C by using go to. You have to assign a label to the address (where you want to jump) and then go to that label.
    Alternatively, if you want only to call function(s), then function pointer can be used.

    But in any case you are not allowed this in C - PC = hhhh

Children
No data