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

Cortex-M3: Changing an ISR address is being reset

Note: This was originally posted on 22nd March 2011 at http://forums.arm.com

Hi,

I have the following code and see some unexpected behavior. If someone could provide some help - my search so far has not led to anything useful.

Code:

printf("Addr %08x\n",*((unsigned int *)164));
*((unsigned int *)164) = 12;
asm volatile ("dmb");
printf("Addr2 %08x\n",*((unsigned int *)164));
printf("Addr3 %08x\n",*((unsigned int *)164));


I would typically expect to get the following printout (lets say the address is initially 0x0008080d):

Addr 0008080d
Addr2 0000000c
Addr3 0000000c


But I get:

Addr 0008080d
Addr2 0000000c
Addr3 0008080d


Now the printf causes some interrupts in the back but I would not expect this to change my ISR address of this peripheral (PWM).

Any thoughts why the address is being reset?

Many Thanks for any help on this.

EDIT:
If I pack the call "*((unsigned int *)164) = 12;" into a function I get the following result, which points that it might be related to something with the actual function call (may it be printf or whatever). But it just adds to my confusion right now.


Addr 0008080d
Addr2 0008080d
Addr3 0008080d
Parents
  • Note: This was originally posted on 22nd March 2011 at http://forums.arm.com

    I wonder whether the change is ever actually there....

    If you have code like this:

      int* pAddr = (int*)0x8000;
      *pAddr = 0x12345678;
      printf("%d", *pAddr);

    It is legal for the compiler to assume that for printf() the memory pointed at will contain 0x12345678, because that is what you've just written to it.  It may therefore not re-read the memory, but simply pass in 0x12345678.

    Try modifying your test case so that you treat l64 as being a volatile pointer.  This will force the compiler to generate code to re-read the memory.

    volatile unsigned int*
Reply
  • Note: This was originally posted on 22nd March 2011 at http://forums.arm.com

    I wonder whether the change is ever actually there....

    If you have code like this:

      int* pAddr = (int*)0x8000;
      *pAddr = 0x12345678;
      printf("%d", *pAddr);

    It is legal for the compiler to assume that for printf() the memory pointed at will contain 0x12345678, because that is what you've just written to it.  It may therefore not re-read the memory, but simply pass in 0x12345678.

    Try modifying your test case so that you treat l64 as being a volatile pointer.  This will force the compiler to generate code to re-read the memory.

    volatile unsigned int*
Children
No data